有些时候我们在后台添加用户,邮箱可能是比较麻烦的事情,如果你想在添加的时候不需要邮箱内容的话,那么可以使用下面的代码
// This will suppress empty email errors when submitting the user form add_action('user_profile_update_errors', 'my_user_profile_update_errors', 10, 3 ); function my_user_profile_update_errors($errors, $update, $user) { $errors->remove('empty_email'); } // This will remove javascript required validation for email input // It will also remove the '(required)' text in the label // Works for new user, user profile and edit user forms add_action('user_new_form', 'my_user_new_form', 10, 1); add_action('show_user_profile', 'my_user_new_form', 10, 1); add_action('edit_user_profile', 'my_user_new_form', 10, 1); function my_user_new_form($form_type) { ?>使用了代码之后,直接输入用户名即可。