以下是一些如何处理neutralization 上的发送密码部分/wp-admin/user-new.php
页码:
想法1:
我们可以覆盖
wp_new_user_notification()
函数,因为它
pluggable:
请尝试以下示例:
if ( ! function_exists( \'wp_new_user_notification\' ) ):
function wp_new_user_notification($user_id, $plaintext_pass = \'\') {
$user = get_userdata( $user_id );
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
// we want to reverse this for the plain text arena of emails.
$blogname = wp_specialchars_decode(get_option(\'blogname\'), ENT_QUOTES);
$message = sprintf(__(\'New user registration on your site %s:\'), $blogname) . "\\r\\n\\r\\n";
$message .= sprintf(__(\'Username: %s\'), $user->user_login) . "\\r\\n\\r\\n";
$message .= sprintf(__(\'E-mail: %s\'), $user->user_email) . "\\r\\n";
@wp_mail(get_option(\'admin_email\'), sprintf(__(\'[%s] New User Registration\'), $blogname), $message);
if ( empty($plaintext_pass) )
return;
// Let\'s remove this user notification part:
/*
$message = sprintf(__(\'Username: %s\'), $user->user_login) . "\\r\\n";
$message .= sprintf(__(\'Password: %s\'), $plaintext_pass) . "\\r\\n";
$message .= wp_login_url() . "\\r\\n";
wp_mail($user->user_email, sprintf(__(\'[%s] Your username and password\'), $blogname), $message);
*/
endif;
如果您不想通知用户,无论“发送密码”设置如何。
在这里,我们刚刚删除了向用户发送通知邮件的代码。
想法2:
让我们通过劫持
show_password_fields
过滤器:
add_action( \'load-user-new.php\', function(){
add_filter( \'show_password_fields\', function( $show ){
?>
<tr class="form-field form-required">
<th scope="row"><label for="pass1"><?php _e(\'Password\'); ?> <span class="description"><?php /* translators: password input field */_e(\'(required)\'); ?></span></label></th>
<td>
<input class="hidden" value=" " /><!-- #24364 workaround -->
<input name="pass1" type="password" id="pass1" autocomplete="off" />
</td>
</tr>
<tr class="form-field form-required">
<th scope="row"><label for="pass2"><?php _e(\'Repeat Password\'); ?> <span class="description"><?php /* translators: password input field */_e(\'(required)\'); ?></span></label></th>
<td>
<input name="pass2" type="password" id="pass2" autocomplete="off" />
<br />
<div id="pass-strength-result"><?php _e(\'Strength indicator\'); ?></div>
<p class="description indicator-hint"><?php _e(\'Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ & ).\'); ?></p>
</td>
</tr>
<?php
return FALSE;
});
});
想法3:我们可以尝试用CSS隐藏它,例如:
add_action( \'load-user-new.php\', function(){
add_action( \'admin_head\', function(){
?><style>#createuser .form-table tr:nth-of-type(9){ display:none; }</style><?php
});
});
如果没有任何额外的用户字段,否则我们可能必须调整
tr:nth-of-type(9)
部分
想法4:使用javascript删除或禁用它。
想法5:
您还可以尝试取消设置
$_POST[\'send_password\']
在进入
wp_new_user_notification
功能:
wp_new_user_notification( $user_id,
isset( $_POST[\'send_password\'] ) ? wp_unslash( $pass1 ) : \'\' );
想法6:
使用output buffering在/wp-admin/user-new.php
分页并替换不需要的HTML块;-)