- Cambios en el envio del email de la dedicatoria para evitar que cuente como SPAM git-svn-id: https://192.168.0.254/svn/Proyectos.ASong2U_Web/trunk@187 cd1a4ea2-8c7f-e448-aada-19d1fee9e1d6
63 lines
2.3 KiB
PHP
63 lines
2.3 KiB
PHP
<?php
|
|
|
|
// Ondemand function to generate tinyurl
|
|
|
|
|
|
function bp_dedication_send_dedication_notification( $post_id, $to_user_email, $from_user_id ) {
|
|
|
|
function bp_dedication_getTinyUrl($url) {
|
|
$tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
|
|
return $tinyurl;
|
|
}
|
|
|
|
global $bp;
|
|
|
|
/* Let's grab both user's names to use in the email. */
|
|
$sender_ud = get_userdata( $from_user_id );
|
|
$sender_username = $sender_ud->user_login;
|
|
$sender_name = bp_core_get_user_displayname( $sender_username );
|
|
|
|
//$reciever_name = bp_core_get_user_displayname( $to_user_id, false );
|
|
|
|
|
|
/* Now we need to construct the URL's that we are going to use in the email */
|
|
//$sender_profile_link = bp_core_get_userlink($from_user_id, false, true);
|
|
|
|
$enc_link = bp_dedication_encode(get_permalink($post_id));
|
|
|
|
$post_link = get_option('siteurl') . '/index.php';
|
|
$post_link = add_query_arg('refid', $enc_link, $post_link);
|
|
|
|
// existe el destinatario como usuario?
|
|
$reciever_ud = get_user_by('email', $to_user_email);
|
|
if ($reciever_ud) {
|
|
$post_link = add_query_arg('y', '1', $post_link);
|
|
}
|
|
|
|
/* Set up and send the message */
|
|
$subject = get_blog_option( 1, 'blogname' ) . '. ' . sprintf( __( '%s has dedicated a song 2u', 'bp-dedication' ), stripslashes($sender_name) );
|
|
|
|
//create a boundary for the email. This
|
|
//$boundary = uniqid('np');
|
|
|
|
// headers - specify your from email address and name here
|
|
// and specify the boundary for the email
|
|
//$headers = "MIME-Version: 1.0\r\n";
|
|
//$headers .= "From: asong2u \r\n";
|
|
//$headers .= "To: ".$to_user_email."\r\n";
|
|
//$headers .= "Content-Type: text/html";
|
|
//$headers .= "Content-Type: multipart/alternative; boundary=" . $boundary . "\r\n";
|
|
|
|
ob_start();
|
|
include(TEMPLATEPATH . '/_mails/mail_new_dedication.php');
|
|
$message = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
|
|
// Send it!
|
|
$result = wp_mail($to_user_email, $subject, $message, $headers);
|
|
}
|
|
add_action( 'bp_dedication_create_new_dedication', 'bp_dedication_send_dedication_notification', 10, 3 );
|
|
|
|
?>
|