Making WordPress.org

Changeset 4144


Ignore:
Timestamp:
09/27/2016 07:21:03 PM (10 years ago)
Author:
coffee2code
Message:

Support Forums: Don't override display value of user role with custom title.

Props netweb.
See #1972.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php

    r4143 r4144  
    66
    77        public function __construct() {
    8                 // If the user has a custom title, use that instead of the forum role.
    9                 add_filter( 'bbp_get_user_display_role', array( $this, 'display_role' ), 10, 2 );
    10 
    118                // Add a Custom Title input to user's profile.
    129                add_action( 'bbp_user_edit_after_name', array( $this, 'add_custom_title_input' ) );
     
    1815                // Custom user contact methods.
    1916                add_filter( 'user_contactmethods', array( $this, 'custom_contact_methods' ) );
    20         }
    21 
    22         /**
    23          * If the user has a custom title, use that instead of the forum role.
    24          *
    25          * @param string  $role    The user's forum role.
    26          * @param int     $user_id The user ID.
    27          * @return string The user's custom forum title, or their forum role.
    28          */
    29         public function display_role( $role, $user_id ) {
    30                 $title = get_user_option( 'title', $user_id );
    31                 if ( ! empty( $title ) ) {
    32                         return esc_html( $title );
    33                 }
    34 
    35                 return $role;
    3617        }
    3718
Note: See TracChangeset for help on using the changeset viewer.