函数文档

welcome_user_msg_filter()

💡 云策文档标注

概述

welcome_user_msg_filter() 是一个 WordPress 过滤器函数,用于确保欢迎用户消息不为空。该函数当前未被使用。

关键要点

  • 函数名:welcome_user_msg_filter(),参数为 $text,返回字符串。
  • 功能:检查传入的 $text 是否为空,若为空则移除 'site_option_welcome_user_email' 过滤器,设置默认欢迎消息并更新站点选项。
  • 状态:该函数在 WordPress MU 3.0.0 版本引入,但目前未在实际中使用。

代码示例

function welcome_user_msg_filter( $text ) {
	if ( ! $text ) {
		remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );

		/* translators: Do not translate USERNAME, PASSWORD, LOGINLINK, SITE_NAME: those are placeholders. */
		$text = __(
			'Howdy USERNAME,

Your new account is set up.

You can log in with the following information:
Username: USERNAME
Password: PASSWORD
LOGINLINK

Thanks!

--The Team @ SITE_NAME'
		);
		update_site_option( 'welcome_user_email', $text );
	}
	return $text;
}

注意事项

  • 函数内部使用 __() 进行国际化处理,但占位符如 USERNAME、PASSWORD 等不应翻译。
  • 相关函数包括 update_site_option()、__() 和 remove_filter(),用于更新选项、翻译文本和移除过滤器。

📄 原文内容

Ensures that the welcome message is not empty. Currently unused.

Parameters

$textstringrequired

Return

string

Source

function welcome_user_msg_filter( $text ) {
	if ( ! $text ) {
		remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );

		/* translators: Do not translate USERNAME, PASSWORD, LOGINLINK, SITE_NAME: those are placeholders. */
		$text = __(
			'Howdy USERNAME,

Your new account is set up.

You can log in with the following information:
Username: USERNAME
Password: PASSWORD
LOGINLINK

Thanks!

--The Team @ SITE_NAME'
		);
		update_site_option( 'welcome_user_email', $text );
	}
	return $text;
}

Changelog

Version Description
MU (3.0.0) Introduced.