返回介绍

wpmu_signup_blog_notification()

发布于 2017-09-11 11:18:47 字数 7052 浏览 1252 评论 0 收藏 0

wpmu_signup_blog_notification( string $domain,  string $path,  string $title,  string $user_login,  string $user_email,  string $key,  array $meta = array() )

Notify user of signup success.


description

This is the notification function used when site registration is enabled.

Filter ‘wpmu_signup_blog_notification’ to bypass this function or replace it with your own notification behavior.

Filter ‘wpmu_signup_blog_notification_email’ and ‘wpmu_signup_blog_notification_subject’ to change the content and subject line of the email sent to newly registered users.


参数

$domain

(string) (Required) The new blog domain.

$path

(string) (Required) The new blog path.

$title

(string) (Required) The site title.

$user_login

(string) (Required) The user's login name.

$user_email

(string) (Required) The user's email address.

$key

(string) (Required) The activation key created in wpmu_signup_blog()

$meta

(array) (Optional) Signup meta data. By default, contains the requested privacy setting and lang_id.

Default value: array()


返回值

(bool)


源代码

File: wp-includes/ms-functions.php

function wpmu_signup_blog_notification( $domain, $path, $title, $user_login, $user_email, $key, $meta = array() ) {
	/**
	 * Filters whether to bypass the new site email notification.
	 *
	 * @since MU
	 *
	 * @param string|bool $domain     Site domain.
	 * @param string      $path       Site path.
	 * @param string      $title      Site title.
	 * @param string      $user_login User login name.
	 * @param string      $user_email User email address.
	 * @param string      $key        Activation key created in wpmu_signup_blog().
	 * @param array       $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
	 */
	if ( ! apply_filters( 'wpmu_signup_blog_notification', $domain, $path, $title, $user_login, $user_email, $key, $meta ) ) {
		return false;
	}

	// Send email with activation link.
	if ( !is_subdomain_install() || get_current_network_id() != 1 )
		$activate_url = network_site_url("wp-activate.php?key=$key");
	else
		$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API

	$activate_url = esc_url($activate_url);
	$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";

	$user = get_user_by( 'login', $user_login );
	$switched_locale = switch_to_locale( get_user_locale( $user ) );

	$message = sprintf(
		/**
		 * Filters the message content of the new blog notification email.
		 *
		 * Content should be formatted for transmission via wp_mail().
		 *
		 * @since MU
		 *
		 * @param string $content    Content of the notification email.
		 * @param string $domain     Site domain.
		 * @param string $path       Site path.
		 * @param string $title      Site title.
		 * @param string $user_login User login name.
		 * @param string $user_email User email address.
		 * @param string $key        Activation key created in wpmu_signup_blog().
		 * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
		 */
		apply_filters( 'wpmu_signup_blog_notification_email',
			__( "To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%s" ),
			$domain, $path, $title, $user_login, $user_email, $key, $meta
		),
		$activate_url,
		esc_url( "http://{$domain}{$path}" ),
		$key
	);
	// TODO: Don't hard code activation link.
	$subject = sprintf(
		/**
		 * Filters the subject of the new blog notification email.
		 *
		 * @since MU
		 *
		 * @param string $subject    Subject of the notification email.
		 * @param string $domain     Site domain.
		 * @param string $path       Site path.
		 * @param string $title      Site title.
		 * @param string $user_login User login name.
		 * @param string $user_email User email address.
		 * @param string $key        Activation key created in wpmu_signup_blog().
		 * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
		 */
		apply_filters( 'wpmu_signup_blog_notification_subject',
			/* translators: New site notification email subject. 1: Network name, 2: New site URL */
			_x( '[%1$s] Activate %2$s', 'New site notification email subject' ),
			$domain, $path, $title, $user_login, $user_email, $key, $meta
		),
		$from_name,
		esc_url( 'http://' . $domain . $path )
	);
	wp_mail( $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/load.php: get_current_network_id()
  • wp-includes/l10n.php: __()
  • wp-includes/l10n.php: _x()
  • wp-includes/formatting.php: esc_url()
  • wp-includes/formatting.php: esc_html()
  • wp-includes/formatting.php: wp_specialchars_decode()
  • wp-includes/pluggable.php: get_user_by()
  • wp-includes/pluggable.php: wp_mail()
  • wp-includes/link-template.php: network_site_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_signup_blog_notification
  • wp-includes/ms-functions.php: wpmu_signup_blog_notification_email
  • wp-includes/ms-functions.php: wpmu_signup_blog_notification_subject
  • wp-includes/ms-load.php: is_subdomain_install()
  • Show 14 more uses Hide more uses

User Contributed Notes

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

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

发布评论

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