返回介绍

wpmu_welcome_user_notification()

发布于 2017-09-11 11:19:27 字数 4958 浏览 980 评论 0 收藏 0

wpmu_welcome_user_notification( int $user_id,  string $password,  array $meta = array() )

Notify a user that their account activation has been successful.


description

Filter ‘wpmu_welcome_user_notification’ to disable or bypass.

Filter ‘update_welcome_user_email’ and ‘update_welcome_user_subject’ to modify the content and subject line of the notification email.


参数

$user_id

(int) (Required) User ID.

$password

(string) (Required) User password.

$meta

(array) (Optional) Signup meta data.

Default value: array()


返回值

(bool)


源代码

File: wp-includes/ms-functions.php

function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) {
	$current_network = get_network();

	/**
 	 * Filters whether to bypass the welcome email after user activation.
	 *
	 * Returning false disables the welcome email.
	 *
	 * @since MU
	 *
	 * @param int    $user_id  User ID.
	 * @param string $password User password.
	 * @param array  $meta     Signup meta data. Default empty array.
	 */
	if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) )
		return false;

	$welcome_email = get_site_option( 'welcome_user_email' );

	$user = get_userdata( $user_id );

	$switched_locale = switch_to_locale( get_user_locale( $user ) );

	/**
	 * Filters the content of the welcome email after user activation.
	 *
	 * Content should be formatted for transmission via wp_mail().
	 *
	 * @since MU
	 *
	 * @param string $welcome_email The message body of the account activation success email.
	 * @param int    $user_id       User ID.
	 * @param string $password      User password.
	 * @param array  $meta          Signup meta data. Default empty array.
	 */
	$welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta );
	$welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
	$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
	$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
	$welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email );

	$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}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
	$message = $welcome_email;

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

	/* translators: New user notification email subject. 1: Network name, 2: New user login */
	$subject = __( 'New %1$s User: %2$s' );

	/**
	 * Filters the subject of the welcome email after user activation.
	 *
	 * @since MU
	 *
	 * @param string $subject Subject of the email.
	 */
	$subject = apply_filters( 'update_welcome_user_subject', sprintf( $subject, $current_network->site_name, $user->user_login) );
	wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );

	if ( $switched_locale ) {
		restore_previous_locale();
	}

	return true;
}

更新日志

Versiondescription
MUIntroduced.

相关函数

Uses

  • wp-includes/l10n.php: restore_previous_locale()
  • wp-includes/l10n.php: switch_to_locale()
  • wp-includes/l10n.php: get_user_locale()
  • wp-includes/ms-blogs.php: get_network()
  • wp-includes/l10n.php: __()
  • wp-includes/formatting.php: esc_html()
  • wp-includes/formatting.php: wp_specialchars_decode()
  • wp-includes/pluggable.php: get_userdata()
  • wp-includes/pluggable.php: wp_mail()
  • wp-includes/general-template.php: wp_login_url()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/option.php: get_site_option()
  • wp-includes/option.php: get_option()
  • wp-includes/ms-functions.php: wpmu_welcome_user_notification
  • wp-includes/ms-functions.php: update_welcome_user_email
  • wp-includes/ms-functions.php: update_welcome_user_subject
  • Show 11 more uses Hide more uses

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文