Skip to:
Content

bbPress.org

Changeset 4299


Ignore:
Timestamp:
11/02/2012 06:29:12 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Capabilities:

  • Add setting callback for default_role.
  • Update verbiage for auto-role/global-access.
  • See #1939.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/admin/settings.php

    r4281 r4299  
    134134
    135135            // Allow global access (on multisite)
     136            '_bbp_default_role' => array(
     137                'title'             => __( 'Default user role', 'bbpress' ),
     138                'callback'          => 'bbp_admin_setting_callback_default_role',
     139                'sanitize_callback' => 'sanitize_text_field',
     140                'args'              => array()
     141            ),
     142
     143            // Allow global access (on multisite)
    136144            '_bbp_allow_global_access' => array(
    137                 'title'             => __( 'Default user role', 'bbpress' ),
     145                'title'             => __( 'Auto role', 'bbpress' ),
    138146                'callback'          => 'bbp_admin_setting_callback_global_access',
    139147                'sanitize_callback' => 'intval',
     
    485493 */
    486494function bbp_admin_setting_callback_global_access() {
    487     global $wp_roles;
    488 
    489     // Load roles if not set
    490     if ( ! isset( $wp_roles ) )
    491         $wp_roles = new WP_Roles();
    492 
    493     $default_role = $wp_roles->role_names[ get_option( 'default_role', 'subscriber' ) ]; ?>
     495?>
    494496
    495497    <input id="_bbp_allow_global_access" name="_bbp_allow_global_access" type="checkbox" id="_bbp_allow_global_access" value="1" <?php checked( bbp_allow_global_access( false ) ); ?> />
    496     <label for="_bbp_allow_global_access"><?php printf( __( 'Automatically assign "%s" role to new, registered visitors.', 'bbpress' ), translate_user_role( $default_role ) ); ?></label>
    497 
    498 <?php
     498    <label for="_bbp_allow_global_access"><?php _e( 'Automatically assign default role to new, registered users upon visiting the site.', 'bbpress' ); ?></label>
     499
     500<?php
     501}
     502
     503/**
     504 * Output forum role selector (for user edit)
     505 *
     506 * @since bbPress (r4284)
     507 */
     508function bbp_admin_setting_callback_default_role() {
     509
     510    $default_role = bbp_get_default_role(); ?>
     511
     512    <select name="_bbp_default_role" id="_bbp_default_role">
     513
     514        <?php foreach ( bbp_get_editable_roles() as $role => $details ) : ?>
     515
     516            <option <?php selected( $default_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>
     517           
     518        <?php endforeach; ?>
     519
     520    </select>
     521
     522    <?php
    499523}
    500524
Note: See TracChangeset for help on using the changeset viewer.