在用户注册新用户帐户时(无需同时注册网站)向用户发送确认请求电子邮件。在单击确认链接之前,用户帐户不会变为活动状态。

原型

wpmu_signup_user_notification( string $user_login, string $user_email, string $key, array $meta = array() )

描述

这是在未请求新站点时使用的通知功能。

参数

$user_login (string) (Required) 用户的登录名。

$user_email (string) (Required) 用户的电子邮件地址。

$key (string) (Required) 在wpmu_signup_user()中创建的激活密钥

$meta (array) (Optional)  注册元数据。

返回值

(bool)  

源文件

路径:wp-includes/ms-functions.php

<?php
...
function wpmu_signup_user_notification( $user_login, $user_email, $key, $meta = array() ) {
	/**
	 * Filters whether to bypass the email notification for new user sign-up.
	 *
	 * @since MU (3.0.0)
	 *
	 * @param string $user_login User login name.
	 * @param string $user_email User email address.
	 * @param string $key        Activation key created in wpmu_signup_user().
	 * @param array  $meta       Signup meta data. Default empty array.
	 */
	if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) )
		return false;
	$user = get_user_by( 'login', $user_login );
	$switched_locale = switch_to_locale( get_user_locale( $user ) );
	// Send email with activation link.
	$admin_email = get_site_option( 'admin_email' );
	if ( $admin_email == '' )
		$admin_email = '[email protected]' . $_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 = sprintf(
		/**
		 * Filters the content of the notification email for new user sign-up.
		 *
		 * Content should be formatted for transmission via wp_mail().
		 *
		 * @since MU (3.0.0)
		 *
		 * @param string $content    Content of the notification email.
		 * @param string $user_login User login name.
		 * @param string $user_email User email address.
		 * @param string $key        Activation key created in wpmu_signup_user().
		 * @param array  $meta       Signup meta data. Default empty array.
		 */
		apply_filters( 'wpmu_signup_user_notification_email',
			__( "To activate your user, please click the following link:nn%snnAfter you activate, you will receive *another email* with your login." ),
			$user_login, $user_email, $key, $meta
		),
		site_url( "wp-activate.php?key=$key" )
	);
	// TODO: Don't hard code activation link.
	$subject = sprintf(
		/**
		 * Filters the subject of the notification email of new user signup.
		 *
		 * @since MU (3.0.0)
		 *
		 * @param string $subject    Subject of the notification email.
		 * @param string $user_login User login name.
		 * @param string $user_email User email address.
		 * @param string $key        Activation key created in wpmu_signup_user().
		 * @param array  $meta       Signup meta data. Default empty array.
		 */
		apply_filters( 'wpmu_signup_user_notification_subject',
			/* translators: New user notification email subject. 1: Network name, 2: New user login */
			_x( '[%1$s] Activate %2$s', 'New user notification email subject' ),
			$user_login, $user_email, $key, $meta
		),
		$from_name,
		$user_login
	);
	wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
	if ( $switched_locale ) {
		restore_previous_locale();
	}
	return true;
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wpmu_signup_user_notification/