Feb 14, 2024 1:15 am
Is there a PHP hook that I can use to filter the member's display name? I need to display a different name based on their role.
1 Reply
Feb 14, 2024 3:31 pm
I figured it out after scouring through your code. Found the following filters. For anyone interested, here is my implementation inside my class.
add_filter( 'wpforo_get_member', [ $this, 'forum_topics_member_name' ], 1000 ); add_filter( 'wpforo_user_display_name', [ $this, 'forum_profile_member_name' ], 1000, 2 ); add_filter( 'wpforo_member_nicename', [ $this, 'forum_profile_nicename' ], 1000, 2 ); ... /** * Forum member name on topics * * @param array $member * @return array */ public function forum_topics_member_name( $member ) { // My own function that gets the name how I want it to $member[ 'display_name' ] = $this->get_user_nickname( $member[ 'userid' ], false ); return $member; } // End forum_topics_member_name /** * Forum member name on profile * * @param string $member * @param array $member * @return string */ public function forum_profile_member_name( $dname, $user ) { // My own function that gets the name how I want it to return $this->get_user_nickname( $user[ 'userid' ], false ); } // End forum_profile_member_name /** * Remove forum nicename on profile * * @param string $member * @param array $member * @return string */ public function forum_profile_nicename( $nicename, $member ) { return ''; } // End forum_profile_nicename