Ticket #1950: meta-1950.2.patch
File meta-1950.2.patch, 1.8 KB (added by , 9 years ago) |
---|
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php
5 5 class Users { 6 6 7 7 public function __construct() { 8 // If the user has a custom title, use that instead of the forum role. 8 9 add_filter( 'bbp_get_user_display_role', array( $this, 'display_role' ), 10, 2 ); 10 11 // Custom user contact methods. 12 add_filter( 'user_contactmethods', array( $this, 'custom_contact_methods' ) ); 9 13 } 10 14 11 15 /** 12 16 * If the user has a custom title, use that instead of the forum role. 13 17 * 14 * @param string $role The user's forum role 15 * @param int $user_id The user id16 * @return string The user's custom forum title, or their forum role 18 * @param string $role The user's forum role. 19 * @param int $user_id The user ID. 20 * @return string The user's custom forum title, or their forum role. 17 21 */ 18 22 public function display_role( $role, $user_id ) { 19 23 $title = get_user_option( 'title', $user_id ); … … 23 27 24 28 return $role; 25 29 } 30 31 /** 32 * Custom contact methods 33 * 34 * @link https://codex.wordpress.org/Plugin_API/Filter_Reference/user_contactmethods 35 * 36 * @param array $user_contact_method Array of contact methods. 37 * @return array An array of contact methods. 38 */ 39 public function custom_contact_methods( $user_contact_method ) { 40 if ( current_user_can( 'moderate' ) ) { 41 42 // Add custom contact fields. 43 $user_contact_method['title'] = __( 'Custom Title', 'wporg-forums' ); 44 } 45 46 return $user_contact_method; 47 } 26 48 }