结果

用户名可以将表单字段值声明为全局值并进行预填充。
这将覆盖通过“记住我”复选框进行的任何设置。
/**
* Changes the default user name to "DEMO"
*
* @return string $user_login
*/
function login_form_username()
{
global $user_login;
return $user_login = \'DEMO\';
}
add_action( \'login_head\', \'login_form_username\' );
密码我找不到任何可用于预填充的内容,所以我要添加一条注释。令人高兴/遗憾的是,有一整套可用的管理UI样式表。所以
.wrap
关于
h2
造型美观。该函数连接到管理挂钩的附加字段挂钩。优先顺序是
0
将其设置在其他字段上方。
/**
* Adds a note beyond the user login name & password field
*
* @return string
*/
function login_form_note()
{
print \'<div class="wrap"><h2 style="text-align: center;">The Password is "DEMO"</h2></div>\';
}
add_action( \'login_form\', \'login_form_note\', 0 );
安全性:隐藏错误由于有人会得到一个视觉证据,证明他在默认情况下输入了一个现有用户名,因此我会将以下内容添加到您的函数中。php文件,以避免告知用户名是否猜对:
/**
* Hide wrong login names
*
* @return string
*/
function no_login_error()
{
return __( \'Wrong Credentials.\' );
}
add_filter( \'login_errors\', \'no_login_error\' );
其他过滤器注意:
如果要替换样式等其他内容,则可以使用login_enqueue_scripts
挂钩也可以使用替换徽标后面的链接login_headerurl
筛选url的筛选器。链接title
可以使用替换login_headertitle
. 这两个触发器都适用于多站点和单站点设置可以使用更改登录消息login_message
过滤器