Exemple #1
0
/**
 * Notify user of signup success.
 *
 * Filter 'wppb_signup_user_notification_filter' to bypass this function or
 * replace it with your own notification behavior.
 *
 * Filter 'wppb_signup_user_notification_email' and
 * 'wppb_signup_user_notification_subject' to change the content
 * and subject line of the email sent to newly registered users.
 *
 * @param string $user The user's login name.
 * @param string $user_email The user's email address.
 * @param array $meta By default, an empty array.
 * @param string $key The activation key created in wppb_signup_user()
 * @return bool
 */
function wppb_signup_user_notification($user, $user_email, $key, $meta = '')
{
    if (!apply_filters('wppb_signup_user_notification_filter', $user, $user_email, $key, $meta)) {
        return false;
    }
    // Send email with activation link.
    $admin_email = get_site_option('admin_email');
    if ($admin_email == '') {
        $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    }
    //$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
    //$from_name = apply_filters ('wppb_signup_user_notification_email_from_field', $from_name);
    //$message_headers = apply_filters ("wppb_signup_user_notification_from", "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n");
    //
    // ksk - Content-Type: multipart/alternative; boundary
    $EOF = "\r\n";
    $from_name = 'Т3С';
    //Письмо с вложением состоит из нескольких частей, которые разделяются разделителем
    // Генерируем разделитель
    $boundary = md5(uniqid(time()));
    //$message_headers = apply_filters ("wppb_signup_user_notification_from", "MIME-Version: 1.0;".$EOF."From: \"{$from_name}\" <{$admin_email}>".$EOF."Content-Type: multipart/mixed; boundary=$boundary".$EOF);
    $message_headers = "MIME-Version: 1.0;" . $EOF;
    $message_headers .= "From: {$from_name} <{$admin_email}>" . $EOF;
    //$message_headers .= "Content-Type: multipart/alternative; boundary=$boundary".$EOF;
    $message_headers .= "Content-Type: multipart/mixed; boundary=\"{$boundary}\"" . $EOF;
    $siteURL = wppb_curpageurl() . wppb_passed_arguments_check() . 'key=' . $key;
    //$subject = sprintf(apply_filters( 'wppb_signup_user_notification_subject', __( '[%1$s] Activate %2$s', 'profilebuilder'), $user, $user_email, $key, $meta ), $from_name, $user);
    //$message = sprintf(apply_filters( 'wppb_signup_user_notification_email', __( "To activate your user, please click the following link:\n\n%s%s%s\n\nAfter you activate, you will receive *another email* with your login.\n\n", "profilebuilder" ),$user, $user_email, $key, $meta), '<a href="'.$siteURL.'">', $siteURL, '</a>.');
    // ksk
    // Текст письма содержится на странице, ID которой указан в параметре t3s_setting_signup_user_notification_page_id
    $subject = 'Подтвердите регистрацию на портале Т3С';
    $page_id = get_option('t3s_setting_signup_user_notification_page_id');
    $page_data = get_page($page_id);
    $page_content = apply_filters('the_content', $page_data->post_content);
    $user_meta = unserialize($meta);
    $fname1 = get_site_url() . '/wp-content/themes/twentytwelve/images/reg_mail_logo.png';
    $fname2 = get_site_url() . '/wp-content/themes/twentytwelve/images/reg_mail_bottom.png';
    $message = "--{$boundary}" . $EOF;
    $message .= 'Content-type: text/html; charset="' . get_option('blog_charset') . '"' . $EOF;
    //$message .= "Content-Transfer-Encoding: base64".$EOF;
    $message .= "Content-Transfer-Encoding: 8bit" . $EOF;
    $message .= $EOF;
    $message .= "<html>" . $EOF;
    $message .= "<head>" . $EOF;
    $message .= "  <meta content=\"text/html; charset=" . get_option('blog_charset') . "\" http-equiv=\"Content-Type\">" . $EOF;
    $message .= "</head>" . $EOF;
    $message .= "<body>" . $EOF;
    $message .= str_replace('#t3s_biz_img_1#', $fname1, str_replace('#t3s_biz_img_2#', $fname2, str_replace('#url#', $siteURL, str_replace('#login#', $user, str_replace('#fio#', $user_meta['first_name'] . ' ' . $user_meta['last_name'], $page_content))))) . $EOF;
    $message .= "</body>" . $EOF;
    $message .= "</html>" . $EOF;
    //
    //wppb_mail( $user_email, $subject, $message, $from_name, '', $user, '', $user_email, 'register_w_email_confirmation', $siteURL, $meta );
    // отправляем письмо
    $result = mail($user_email, $subject, $message, $message_headers);
    return $result;
}
/**
 * Notify user of signup success.
 *
 * Filter 'wppb_signup_user_notification_filter' to bypass this function or
 * replace it with your own notification behavior.
 *
 * Filter 'wppb_signup_user_notification_email' and
 * 'wppb_signup_user_notification_subject' to change the content
 * and subject line of the email sent to newly registered users.
 *
 * @param string $user The user's login name.
 * @param string $user_email The user's email address.
 * @param array $meta By default, an empty array.
 * @param string $key The activation key created in wppb_signup_user()
 * @return bool
 */
function wppb_signup_user_notification($user, $user_email, $key, $meta = '')
{
    if (!apply_filters('wppb_signup_user_notification_filter', $user, $user_email, $key, $meta)) {
        return false;
    }
    // Send email with activation link.
    $admin_email = get_site_option('admin_email');
    if ($admin_email == '') {
        $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    }
    $from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name'));
    $from_name = apply_filters('wppb_signup_user_notification_email_from_field', $from_name);
    $message_headers = apply_filters("wppb_signup_user_notification_from", "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n");
    $siteURL = wppb_curpageurl() . wppb_passed_arguments_check() . 'key=' . $key;
    $subject = sprintf(apply_filters('wppb_signup_user_notification_subject', __('[%1$s] Activate %2$s', 'profilebuilder'), $user, $user_email, $key, $meta), $from_name, $user);
    $message = sprintf(apply_filters('wppb_signup_user_notification_email', __("To activate your user, please click the following link:\n\n%s%s%s\n\nAfter you activate, you will receive *another email* with your login.\n\n", "profilebuilder"), $user, $user_email, $key, $meta), '<a href="' . $siteURL . '">', $siteURL, '</a>.');
    wppb_mail($user_email, $subject, $message, $from_name, '', $user, '', $user_email, 'register_w_email_confirmation', $siteURL, $meta);
    return true;
}