Skip to:
Content

bbPress.org

Changeset 4338


Ignore:
Timestamp:
11/05/2012 01:49:35 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Capabilities:

  • Add "Forum Role" column to single-site users list.
  • Fixes issue where there was no immediate way to see what users had what forums role at a glance.
  • Props jmdodd.
  • Fixes #2012.
File:
1 edited

Legend:

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

    r4330 r4338  
    4949                // User profile edit/display actions
    5050                add_action( 'edit_user_profile', array( $this, 'secondary_role_display' ) );
     51
     52                // WordPress user screen
     53                add_filter( 'manage_users_columns',       array( $this, 'user_role_column' )        );
     54                add_filter( 'manage_users_custom_column', array( $this, 'user_role_row'    ), 10, 3 );
    5155        }
    5256
     
    102106                <?php
    103107        }
     108
     109        /**
     110         * Add Forum Role column to the WordPress Users table, and change the
     111         * core role title to "Site Role"
     112         *
     113         * @since bbPress (r4337)
     114         *
     115         * @param array $columns Users table columns
     116         * @return array $columns
     117         */
     118        function user_role_column( $columns = array() ) {
     119                $columns['role']          = __( 'Site Role',  'bbpress' );
     120        $columns['bbp_user_role'] = __( 'Forum Role', 'bbpress' );
     121
     122                return $columns;
     123        }
     124
     125        /**
     126         * Return user's forums role for display in the WordPress Users list table
     127         *
     128         * @since bbPress (r4337)
     129         *
     130         * @param string $retval
     131         * @param string $column_name
     132         * @param int $user_id
     133         *
     134         * @return string Displayable bbPress user role
     135         */
     136        function user_role_row( $retval = '', $column_name = '', $user_id = 0 ) {
     137
     138                // Only looking for bbPress's user role column
     139                if ( 'bbp_user_role' == $column_name ) {
     140                       
     141                        // Get the users role
     142                        $user_role = bbp_get_user_role( $user_id );
     143                        $retval    = false;
     144
     145                        // Translate user role for display
     146                        if ( ! empty( $user_role ) ) {
     147                                $roles  = bbp_get_editable_roles();
     148                                $retval = translate_user_role( $roles[$user_role]['name'] );
     149                        }
     150                }
     151
     152                // Pass retval through
     153                return $retval;
     154        }
    104155}
    105156new BBP_Users_Admin();
Note: See TracChangeset for help on using the changeset viewer.