wpmu_signup_blog_notification

函数
wpmu_signup_blog_notification ( $domain, $path, $title, $user_login, $user_email, $key, $meta = array() )
参数
  • (string) $domain The new blog domain.
    Required:
  • (string) $path The new blog path.
    Required:
  • (string) $title The site title.
    Required:
  • (string) $user_login The user's login name.
    Required:
  • (string) $user_email The user's email address.
    Required:
  • (string) $key The activation key created in wpmu_signup_blog()
    Required:
  • (array) $meta Optional. Signup meta data. By default, contains the requested privacy setting and lang_id.
    Required:
    Default: array()
返回值
  • (bool)
定义位置
相关方法
wpmu_signup_user_notificationwp_new_blog_notificationwpmu_welcome_notificationwpmu_signup_blogwpmu_new_site_admin_notification
引入
-
弃用
-

wpmu_signup_blog_notification – 此函数在站点创建时向新站点的管理员发送电子邮件通知。

当用户注册一个新网站时,向他们发送一封确认请求的电子邮件。在确认链接被点击之前,新网站将不会被激活。

这是在启用网站注册时使用的通知函数。

过滤器 {@see ‘wpmu_signup_blog_notification’} 可以绕过这个函数,或者用你自己的通知行为来替换它。

过滤{@see ‘wpmu_signup_blog_notification_email’}和{@see ‘wpmu_signup_blog_notification_subject’}来改变发送给新注册用户的邮件的内容和主题行。

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 (3.0.0)
	 *
	 * @param string|false $domain     Site domain, or false to prevent the email from sending.
	 * @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@' . wp_parse_url( network_home_url(), PHP_URL_HOST );
	}

	$from_name       = ( '' !== get_site_option( 'site_name' ) ) ? esc_html( get_site_option( 'site_name' ) ) : 'WordPress';
	$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 (3.0.0)
		 *
		 * @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',
			/* translators: New site notification email. 1: Activation URL, 2: New site URL. */
			__( "To activate your site, please click the following link:nn%1$snnAfter you activate, you will receive *another email* with your login.nnAfter you activate, you can visit your site here:nn%2$s" ),
			$domain,
			$path,
			$title,
			$user_login,
			$user_email,
			$key,
			$meta
		),
		$activate_url,
		esc_url( "http://{$domain}{$path}" ),
		$key
	);

	$subject = sprintf(
		/**
		 * Filters the subject of the new blog notification email.
		 *
		 * @since MU (3.0.0)
		 *
		 * @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 title, 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;
}

常见问题

FAQs
查看更多 >