Esempio n. 1
0
/**
 * Output forum role selector (for user edit)
 *
 * @since 2.2.0 bbPress (r4284)
 */
function bbp_edit_user_forums_role()
{
    // Return if no user is being edited
    if (!bbp_is_single_user_edit()) {
        return;
    }
    // Get the user's current forum role
    $user_role = bbp_get_user_role(bbp_get_displayed_user_id());
    // Get the folum roles
    $dynamic_roles = bbp_get_dynamic_roles();
    // Only keymasters can set other keymasters
    if (!bbp_is_user_keymaster()) {
        unset($dynamic_roles[bbp_get_keymaster_role()]);
    }
    ?>

	<select name="bbp-forums-role" id="bbp-forums-role">
		<option value=""><?php 
    esc_html_e('&mdash; No role for these forums &mdash;', 'bbpress');
    ?>
</option>

		<?php 
    foreach ($dynamic_roles as $role => $details) {
        ?>

			<option <?php 
        selected($user_role, $role);
        ?>
 value="<?php 
        echo esc_attr($role);
        ?>
"><?php 
        echo bbp_translate_user_role($details['name']);
        ?>
</option>

		<?php 
    }
    ?>

	</select>

	<?php 
}
Esempio n. 2
0
/**
 * Allow global access setting field
 *
 * @since 2.0.0 bbPress (r3378)
 *
 * @uses checked() To display the checked attribute
 */
function bbp_admin_setting_callback_global_access()
{
    // Get the default role once rather than loop repeatedly below
    $default_role = bbp_get_default_role();
    // Start the output buffer for the select dropdown
    ob_start();
    ?>

	</label>
	<label for="_bbp_default_role">
		<select name="_bbp_default_role" id="_bbp_default_role" <?php 
    bbp_maybe_admin_setting_disabled('_bbp_default_role');
    ?>
>
		<?php 
    foreach (bbp_get_dynamic_roles() as $role => $details) {
        ?>

			<option <?php 
        selected($default_role, $role);
        ?>
 value="<?php 
        echo esc_attr($role);
        ?>
"><?php 
        echo bbp_translate_user_role($details['name']);
        ?>
</option>

		<?php 
    }
    ?>
		</select>

	<?php 
    $select = ob_get_clean();
    ?>

	<label for="_bbp_allow_global_access">
		<input name="_bbp_allow_global_access" id="_bbp_allow_global_access" type="checkbox" value="1" <?php 
    checked(bbp_allow_global_access(true));
    bbp_maybe_admin_setting_disabled('_bbp_allow_global_access');
    ?>
 />
		<?php 
    printf(esc_html__('Automatically give registered visitors the %s forum role', 'bbpress'), $select);
    ?>
	</label>

<?php 
}
Esempio n. 3
0
/**
 * Gets a translated role name from a role ID
 *
 * @since 2.3.0 bbPress (r4792)
 * @since 2.6.0 bbPress (r6117) Use bbp_translate_user_role()
 *
 * @param string $role_id
 * @return string Translated role name
 */
function bbp_get_dynamic_role_name($role_id = '')
{
    $roles = bbp_get_dynamic_roles();
    $role = isset($roles[$role_id]) ? bbp_translate_user_role($roles[$role_id]['name']) : '';
    return apply_filters('bbp_get_dynamic_role_name', $role, $role_id, $roles);
}
Esempio n. 4
0
 /**
  * Return user's forums role for display in the WordPress Users list table
  *
  * @since 2.2.0 bbPress (r4337)
  *
  * @param string $retval
  * @param string $column_name
  * @param int $user_id
  *
  * @return string Displayable bbPress user role
  */
 public static function user_role_row($retval = '', $column_name = '', $user_id = 0)
 {
     // Only looking for bbPress's user role column
     if ('bbp_user_role' === $column_name) {
         // Get the users role
         $user_role = bbp_get_user_role($user_id);
         $retval = false;
         // Translate user role for display
         if (!empty($user_role)) {
             $roles = bbp_get_dynamic_roles();
             $retval = bbp_translate_user_role($roles[$user_role]['name']);
         }
     }
     // Pass retval through
     return $retval;
 }