为站点管理员提供在添加新用户时跳过确认电子邮件的选项

时间:2014-12-10 作者:need-help

在wordpress multisite中,当我们给站点管理员添加新用户的选项时,站点管理员没有“复选框”来添加新用户,而不发送带有链接激活的用户电子邮件(参见屏幕截图)

enter image description here

如何将此选项添加到站点管理?

2 个回复
SO网友:shlomi

将此粘贴到functions.php 文件:

function my_skip_confirmation_email() {
    if ( is_multisite() && current_user_can( \'create_users\' ) ) { ?>

    <table class="form-table">
        <tr>
            <th scope="row"><?php _e( \'Skip Confirmation Email\' ); ?></th>
            <td>
                <input type="checkbox" name="noconfirmation" id="noconfirmation" value="1" />
                <label for="noconfirmation"><?php _e( \'Add the user without sending an email that requires their confirmation.\' ); ?></label>
            </td>
        </tr>
    </table>
    <?php }
}
add_action( \'user_new_form\', \'my_skip_confirmation_email\' );

SO网友:Sanat Kumar Panda

将以下内容添加到函数中。php文件

    function skp_custom_user_create_fields($user){
    if (!is_super_admin( $user_id )) {
?>

    <table class="form-table">
        <tr>
            <th scope="row"><?php _e(\'Skip Confirmation Email\') ?></th>
            <td><input type = "checkbox" name = "noconfirmation" value = "1" <?php checked( $_POST[\'noconfirmation\'], 1 ); ?> /> Add the user without sending an email that requires their confirmation.</td>
        </tr>
    </table>
<?php
    }
}
add_action("user_new_form", "skp_custom_user_create_fields");

function skp_auto_activate_users($user, $user_email, $key, $meta){

    if(!current_user_can(\'manage_options\'))
        return false;

    if (!empty($_POST[\'noconfirmation\']) && $_POST[\'noconfirmation\'] == 1) {
        wpmu_activate_signup($key);
          return false;
    }
}
add_filter(\'wpmu_signup_user_notification\', \'skp_auto_activate_users\', 10, 4);
那就行了。

结束