Making WordPress.org

Ticket #1950: meta-1950.2.patch

File meta-1950.2.patch, 1.8 KB (added by netweb, 8 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php

     
    55class Users {
    66
    77        public function __construct() {
     8                // If the user has a custom title, use that instead of the forum role.
    89                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' ) );
    913        }
    1014
    1115        /**
    1216         * If the user has a custom title, use that instead of the forum role.
    1317         *
    14          * @param string $role The user's forum role
    15          * @param int $user_id The user id
    16          * @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.
    1721         */
    1822        public function display_role( $role, $user_id ) {
    1923                $title = get_user_option( 'title', $user_id );
     
    2327
    2428                return $role;
    2529        }
     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        }
    2648}