wordpress后台添加用户邮箱必填项解除

wordpress在4.0之后就已经取消了数据库的用户邮箱的必填项,现在看来邮箱确实没什么用,近期在项目中批量载入用户时,就在wordpress中的邮箱必填项中收到了阻碍。
解除很多人多想着在form上面链接的user-editor.php或者是user-new.php中做限制,但是这样子有污染代码的嫌疑
直接屏蔽即可
在\wp-admin\includes\user.php中有个/ checking email address /的模块,注释即可

1
2
3
4
5
6
7
8
/* checking email address */
// if ( empty( $user->user_email ) ) {
// $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please enter an email address.' ), array( 'form-field' => 'email' ) );
// } elseif ( !is_email( $user->user_email ) ) {
// $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The email address isn’t correct.' ), array( 'form-field' => 'email' ) );
// } elseif ( ( $owner_id = email_exists($user->user_email) ) && ( !$update || ( $owner_id != $user->ID ) ) ) {
// $errors->add( 'email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) );
// }

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×