您可以使用wpmu_validate_user_signup
筛选以删除错误,然后定义WP_IMPORTING
只是为了跳过email_exist()
登记入住wp_insert_user()
功能:
add_filter(\'wpmu_validate_user_signup\', \'skip_email_exist\');
function skip_email_exist($result){
if(isset($result[\'errors\']->errors[\'user_email\']) && ($key = array_search(__(\'Sorry, that email address is already used!\'), $result[\'errors\']->errors[\'user_email\'])) !== false) {
unset($result[\'errors\']->errors[\'user_email\'][$key]);
if (empty($result[\'errors\']->errors[\'user_email\'])) unset($result[\'errors\']->errors[\'user_email\']);
}
define( \'WP_IMPORTING\', \'SKIP_EMAIL_EXIST\' );
return $result;
}
UPDATE: 对于非多站点设置,请尝试以下代码:
add_filter(\'pre_user_email\', \'skip_email_exist\');
function skip_email_exist($user_email){
define( \'WP_IMPORTING\', \'SKIP_EMAIL_EXIST\' );
return $user_email;
}