newblog_notify_siteadmin

函式
newblog_notify_siteadmin ( $blog_id, $deprecated = '' )
引數
  • (WP_Site|int) $blog_id The new site's object or ID.
    Required:
  • (string) $deprecated Not used.
    Required:
    Default: (empty)
返回值
  • (bool)
定義位置
相關方法
newuser_notify_siteadminwp_new_blog_notificationis_site_adminwpmu_signup_blog_notificationwp_notify_postauthor
引入
-
棄用
-

newblog_notify_siteadmin: 當在網路安裝中建立了一個新的站點,並向站點管理員傳送通知郵件時,這個動作鉤子被觸發。

通知網路管理員一個新的網站已經被啟用。

過濾{@see ‘newblog_notify_siteadmin’}來改變通知郵件的內容。

function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
	if ( is_object( $blog_id ) ) {
		$blog_id = $blog_id->blog_id;
	}

	if ( 'yes' !== get_site_option( 'registrationnotification' ) ) {
		return false;
	}

	$email = get_site_option( 'admin_email' );

	if ( is_email( $email ) == false ) {
		return false;
	}

	$options_site_url = esc_url( network_admin_url( 'settings.php' ) );

	switch_to_blog( $blog_id );
	$blogname = get_option( 'blogname' );
	$siteurl  = site_url();
	restore_current_blog();

	$msg = sprintf(
		/* translators: New site notification email. 1: Site URL, 2: User IP address, 3: URL to Network Settings screen. */
		__(
			'New Site: %1$s
URL: %2$s
Remote IP address: %3$s

Disable these notifications: %4$s'
		),
		$blogname,
		$siteurl,
		wp_unslash( $_SERVER['REMOTE_ADDR'] ),
		$options_site_url
	);
	/**
	 * Filters the message body of the new site activation email sent
	 * to the network administrator.
	 *
	 * @since MU (3.0.0)
	 * @since 5.4.0 The `$blog_id` parameter was added.
	 *
	 * @param string     $msg     Email body.
	 * @param int|string $blog_id The new site's ID as an integer or numeric string.
	 */
	$msg = apply_filters( 'newblog_notify_siteadmin', $msg, $blog_id );

	/* translators: New site notification email subject. %s: New site URL. */
	wp_mail( $email, sprintf( __( 'New Site Registration: %s' ), $siteurl ), $msg );

	return true;
}

常見問題

FAQs
檢視更多 >