wp_new_blog_notification

函数
wp_new_blog_notification ( $blog_title, $blog_url, $user_id, $password )
参数
  • (string) $blog_title Site title.
    Required:
  • (string) $blog_url Site URL.
    Required:
  • (int) $user_id Administrator's user ID.
    Required:
  • (string) $password Administrator's password. Note that a placeholder message is usually passed instead of the actual password.
    Required:
定义位置
相关方法
wpmu_signup_blog_notificationwp_new_user_notificationwpmu_welcome_notificationwp_send_new_user_notificationsnewblog_notify_siteadmin
引入
2.1.0
弃用
-

wp_new_blog_notification: 这个钩子用于在WordPress网络上创建新站点时向站点管理员发送电子邮件通知。它可以用来添加额外的收件人或修改电子邮件信息。

通知网站管理员,WordPress的安装已经完成。

向新的管理员发送一封电子邮件,告诉他们安装已经完成,并为他们提供一个登录凭证的记录。

function wp_new_blog_notification( $blog_title, $blog_url, $user_id, $password ) {
		$user      = new WP_User( $user_id );
		$email     = $user->user_email;
		$name      = $user->user_login;
		$login_url = wp_login_url();

		$message = sprintf(
			/* translators: New site notification email. 1: New site URL, 2: User login, 3: User password or password reset link, 4: Login URL. */
			__(
				'Your new WordPress site has been successfully set up at:

%1$s

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

Username: %2$s
Password: %3$s
Log in here: %4$s

We hope you enjoy your new site. Thanks!

--The WordPress Team
https://wordpress.org/
'
			),
			$blog_url,
			$name,
			$password,
			$login_url
		);

		$installed_email = array(
			'to'      => $email,
			'subject' => __( 'New WordPress Site' ),
			'message' => $message,
			'headers' => '',
		);

		/**
		 * Filters the contents of the email sent to the site administrator when WordPress is installed.
		 *
		 * @since 5.6.0
		 *
		 * @param array $installed_email {
		 *     Used to build wp_mail().
		 *
		 *     @type string $to      The email address of the recipient.
		 *     @type string $subject The subject of the email.
		 *     @type string $message The content of the email.
		 *     @type string $headers Headers.
		 * }
		 * @param WP_User $user          The site administrator user object.
		 * @param string  $blog_title    The site title.
		 * @param string  $blog_url      The site URL.
		 * @param string  $password      The site administrator's password. Note that a placeholder message
		 *                               is usually passed instead of the user's actual password.
		 */
		$installed_email = apply_filters( 'wp_installed_email', $installed_email, $user, $blog_title, $blog_url, $password );

		wp_mail(
			$installed_email['to'],
			$installed_email['subject'],
			$installed_email['message'],
			$installed_email['headers']
		);
	}
endif;

if ( ! function_exists( 'wp_upgrade' ) ) :
	/**
	 * Runs WordPress Upgrade functions.
	 *
	 * Upgrades the database if needed during a site update.
	 *
	 * @since 2.1.0
	 *
	 * @global int  $wp_current_db_version The old (current) database version.
	 * @global int  $wp_db_version         The new database version.
	 * @global wpdb $wpdb                  WordPress database abstraction object.
	 */

常见问题

FAQs
查看更多 >