wpmu_welcome_notification()博客激活成功时发送欢迎邮件(多站点)

目录

描述

Notify a user that his/her blog activation has been successful.

wpmu_welcome_notification() 描述

用法

<?php wpmu_welcome_notification($blog_id$user_id$password$title$meta ); ?>

wpmu_welcome_notification() 用法

参数

$blog_id

(integer) (必填) The blog ID

默认值: None

$user_id

(integer) (必填) The user's ID

默认值: None

$password

(string) (必填) The password

默认值: None

$title

(string) (必填) The blog's new title

默认值: None

$meta

(array) (可选) Not used in the default function, but is passed along to hooks for customization.

默认值: empty string

wpmu_welcome_notification() 参数

示例

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

wpmu_welcome_notification() 示例

注意

Filter 'wpmu_welcome_notification' to disable or bypass.

Filter 'update_welcome_email' and 'update_welcome_subject' to modify the content and subject line of the notification email.

wpmu_welcome_notification() 注意

历史

添加于 版本: MU

wpmu_welcome_notification() 历史

源文件

wpmu_welcome_notification() 函数的代码位于 wp-includes/ms-functions.php

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Notify a user that their blog activation has been successful.
 *
 * Filter 'wpmu_welcome_notification' to disable or bypass.
 *
 * Filter 'update_welcome_email' and 'update_welcome_subject' to
 * modify the content and subject line of the notification email.
 *
 * @since MU
 *
 * @param int    $blog_id
 * @param int    $user_id
 * @param string $password
 * @param string $title    The new blog's title
 * @param array  $meta     Optional. Not used in the default function, but is passed along to hooks for customization.
 * @return bool
 */
function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) {
	$current_site = get_current_site();

	/**
	 * Filter whether to bypass the welcome email after site activation.
	 *
	 * Returning false disables the welcome email.
	 *
	 * @since MU
	 *
	 * @param int|bool $blog_id  Blog ID.
	 * @param int      $user_id  User ID.
	 * @param string   $password User password.
	 * @param string   $title    Site title.
	 * @param array    $meta     Signup meta data.
	 */
	if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) )
		return false;

	$welcome_email = get_site_option( 'welcome_email' );
	if ( $welcome_email == false ) {
		/* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
		$welcome_email = __( 'Howdy USERNAME,

Your new SITE_NAME site has been successfully set up at:
BLOG_URL

You can log in to the administrator account with the following information:

Username: USERNAME
Password: PASSWORD
Log in here: BLOG_URLwp-login.php

We hope you enjoy your new site. Thanks!

--The Team @ SITE_NAME' );
	}

	$url = get_blogaddress_by_id($blog_id);
	$user = get_userdata( $user_id );

	$welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email );
	$welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email );
	$welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email );
	$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
	$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );

	/**
	 * Filter the content of the welcome email after site activation.
	 *
	 * Content should be formatted for transmission via wp_mail().
	 *
	 * @since MU
	 *
	 * @param string $welcome_email Message body of the email.
	 * @param int    $blog_id       Blog ID.
	 * @param int    $user_id       User ID.
	 * @param string $password      User password.
	 * @param string $title         Site title.
	 * @param array  $meta          Signup meta data.
	 */
	$welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta );
	$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' ) );
	$message_headers = "From: "{$from_name}" <{$admin_email}>
" . "Content-Type: text/plain; charset="" . get_option('blog_charset') . ""
";
	$message = $welcome_email;

	if ( empty( $current_site->site_name ) )
		$current_site->site_name = 'WordPress';

	/**
	 * Filter the subject of the welcome email after site activation.
	 *
	 * @since MU
	 *
	 * @param string $subject Subject of the email.
	 */
	$subject = apply_filters( 'update_welcome_subject', sprintf( __( 'New %1$s Site: %2$s' ), $current_site->site_name, wp_unslash( $title ) ) );
	wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
	return true;
}

wpmu_welcome_notification() 源文件

相关