wpmu_signup_blog_notification()提示用户注册成功(多站点)

目录

描述

Notify user of signup success.

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

wpmu_signup_blog_notification() 描述

用法

<?php wpmu_signup_blog_notification($domain$path$title,
    
$user$user_email$key$meta); ?>

wpmu_signup_blog_notification() 用法

参数

$domain

(string) (必填) The requested domain

默认值: None

$path

(string) (必填) The requested path

默认值: None

$title

(string) (必填) The requested site title

默认值: None

$user

(string) (必填) The user's requested login name

默认值: None

$user_email

(string) (必填) The user's email address

默认值: None

$key

(string) (必填) The activation key created in wpmu_signup_blog()

默认值: None

$meta

(array) (必填) By default, contains the requested privacy setting and lang_id.

默认值: None

wpmu_signup_blog_notification() 参数

示例

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

wpmu_signup_blog_notification() 示例

注意

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.

wpmu_signup_blog_notification() 注意

历史

添加于 版本: MU

wpmu_signup_blog_notification() 历史

源文件

wpmu_signup_blog_notification() 函数的代码位于 wp-includes/ms-functions.php

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Notify user of signup success.
 *
 * 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.
 *
 * @since MU
 *
 * @param string $domain     The new blog domain.
 * @param string $path       The new blog path.
 * @param string $title      The site title.
 * @param string $user       The user's login name.
 * @param string $user_email The user's email address.
 * @param string $key        The activation key created in wpmu_signup_blog()
 * @param array  $meta       By default, contains the requested privacy setting and lang_id.
 * @return bool
 */
function wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta = array() ) {
	/**
	 * Filter 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       User login name.
	 * @param string      $user_email User email address.
	 * @param string      $key        Activation key created in wpmu_signup_blog().
	 * @param array       $meta       By default, contains the requested privacy setting and lang_id.
	 */
	if ( ! apply_filters( 'wpmu_signup_blog_notification', $domain, $path, $title, $user, $user_email, $key, $meta ) ) {
		return false;
	}

	// Send email with activation link.
	if ( !is_subdomain_install() || get_current_site()->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}>
" . "Content-Type: text/plain; charset="" . get_option('blog_charset') . ""
";
	$message = sprintf(
		/**
		 * Filter 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       User login name.
		 * @param string $user_email User email address.
		 * @param string $key        Activation key created in wpmu_signup_blog().
		 * @param array  $meta       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:

%s

After you activate, you will receive *another email* with your login.

After you activate, you can visit your site here:

%s" ),
			$domain, $path, $title, $user, $user_email, $key, $meta
		),
		$activate_url,
		esc_url( "http://{$domain}{$path}" ),
		$key
	);
	// TODO: Don't hard code activation link.
	$subject = sprintf(
		/**
		 * Filter 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       User login name.
		 * @param string $user_email User email address.
		 * @param string $key        Activation key created in wpmu_signup_blog().
		 * @param array  $meta       By default, contains the requested privacy setting and lang_id.
		 */
		apply_filters( 'wpmu_signup_blog_notification_subject',
			__( '[%1$s] Activate %2$s' ),
			$domain, $path, $title, $user, $user_email, $key, $meta
		),
		$from_name,
		esc_url( 'http://' . $domain . $path )
	);
	wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
	return true;
}

wpmu_signup_blog_notification() 源文件

相关