wp_dropdown_roles example

<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ); ?> <table class="form-table" role="presentation"> <tr class="form-field form-required"> <th scope="row"><label for="adduser-email"><?php echo esc_html( $label ); ?></label></th> <td><input name="email" type="<?php echo esc_attr( $type ); ?>" id="adduser-email" class="wp-suggest-user" value="" /></td> </tr> <tr class="form-field"> <th scope="row"><label for="adduser-role"><?php _e( 'Role' ); ?></label></th> <td><select name="role" id="adduser-role"> <?php wp_dropdown_roles( get_option( 'default_role' ) ); ?> </select> </td> </tr> <?php if ( current_user_can( 'manage_network_users' ) ) { ?> <tr> <th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th> <td> <input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" /> <label for="adduser-noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation.' ); ?></label> </td> </tr>
?> <div class="alignleft actions"> <?php if ( current_user_can( 'promote_users' ) && $this->has_items() ) : ?> <label class="screen-reader-text" for="<?php echo $id; ?>"> <?php             /* translators: Hidden accessibility text. */
            _e( 'Change role to&hellip;' );
            ?> </label> <select name="<?php echo $id; ?>" id="<?php echo $id; ?>"> <option value=""><?php _e( 'Change role to&hellip;' ); ?></option> <?php wp_dropdown_roles(); ?> <option value="none"><?php _e( '&mdash; No role for this site &mdash;' ); ?></option> </select> <?php             submit_button( __( 'Change' ), '', $button_id, false );
        endif;

        /** * Fires just before the closing div containing the bulk role-change controls * in the Users list table. * * @since 3.5.0 * @since 4.6.0 The `$which` parameter was added. * * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. */
_e( 'Membership' );
    ?> </span></legend><label for="users_can_register"> <input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked( '1', get_option( 'users_can_register' ) ); ?> /> <?php _e( 'Anyone can register' ); ?></label> </fieldset></td> </tr> <tr> <th scope="row"><label for="default_role"><?php _e( 'New User Default Role' ); ?></label></th> <td> <select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option( 'default_role' ) ); ?></select> </td> </tr> <?php }

$languages    = get_available_languages();
$translations = wp_get_available_translations();
if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages, true ) ) {
    $languages[] = WPLANG;
}
<?php if ( ! IS_PROFILE_PAGE && ! is_network_admin() && current_user_can( 'promote_user', $profile_user->ID ) ) : ?> <tr class="user-role-wrap"> <th><label for="role"><?php _e( 'Role' ); ?></label></th> <td> <select name="role" id="role"> <?php                                     // Compare user role against currently editable roles.                                     $user_roles = array_intersect( array_values( $profile_user->roles )array_keys( get_editable_roles() ) );
                                    $user_role  = reset( $user_roles );

                                    // Print the full list of roles with the primary one selected.                                     wp_dropdown_roles( $user_role );

                                    // Print the 'no role' option. Make it selected if the user has no role yet.                                     if ( $user_role ) {
                                        echo '<option value="">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
                                    } else {
                                        echo '<option value="" selected="selected">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
                                    }
                                    ?> </select> </td> </tr>
<?php echo esc_attr( $id ); ?>" /> <table class="form-table" role="presentation"> <tr> <th scope="row"><label for="newuser"><?php _e( 'Username' ); ?></label></th> <td><input type="text" class="regular-text wp-suggest-user" name="newuser" id="newuser" /></td> </tr> <tr> <th scope="row"><label for="new_role_adduser"><?php _e( 'Role' ); ?></label></th> <td><select name="new_role" id="new_role_adduser"> <?php             switch_to_blog( $id );
            wp_dropdown_roles( get_option( 'default_role' ) );
            restore_current_blog();
            ?> </select></td> </tr> </table> <?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ); ?> <?php submit_button( __( 'Add User' ), 'primary', 'add-user', true, array( 'id' => 'submit-add-existing-user' ) ); ?> </form> <?php endif; ?> <?php
Home | Imprint | This part of the site doesn't use cookies.