I’ve been looking around for a bit of time for a solution to a problem. I have Two different Member Types each with their own WordPress Role. I need one Member Type (Teachers) to have the Full Name (First and Last Names) displayed and the other (Students) the username or “nicename” displayed.
I found a plugin, “Display Name Publicly As” that may do what I need at:
https://memberfix.rocks/change-display-name-publicly-as/
I was hoping to find a simpler solution.
Hi RES,
Thank you for the question.It is a simple customization. you can do it with a couple of lines of code.
I will rephrase your question and share the code.
Here is the code that will show nice name for all users except the teacher(for them, let the full name work).
/** * Filter Display Name. */ add_filter( 'bp_core_get_user_displayname', function ( $name, $user_id ) { if ( ! bp_has_member_type( $user_id, 'teacher' ) ) { $name = bp_members_get_user_nicename( $user_id ); } return $name; }, 10, 2 ); /** * Filter Displayed User full name for BuddyPress. */ add_filter( 'bp_displayed_user_fullname', function ( $name ) { if ( ! bp_has_member_type( bp_displayed_user_id(), 'teacher' ) ) { $name = bp_members_get_user_nicename( bp_displayed_user_id() ); } return $name; } );
You can put it in bp-custom.php in plugins directory or functions.php of your theme.
Regards
BrajeshI appreciate your response very much. Unfortunately I tested it in both a BuddyPress and BuddyBoss setups (both multisite) and I could not get it to work. I tried various scenarios. I’m running WordPress version 5.4.2 and PHP version 7.4.4.
I feel as though I’m already asking a lot but I have a request. I believe the code reads, “if not teacher, display nicename. I have different levels of teachers so I think it would work better if the code was “if student, full name”. I hope that’s clear.
Thank you very, very much.
Here are the plugins I’m using on the BuddyPress site:
Astra Pro Version 2.5.1 by Brainstorm Force
Autoptimize Version 2.7.3 by Frank Goossens (futtta) (Latest version: 2.7.5)
BP Profile Search Version 5.3.3 by Andrea Tarantini
BuddyPress Version 6.1.0 by The BuddyPress Community
BuddyPress Admin Only Profile Fields Version 1.2 by Ashley Rich
BuddyPress Member Type Generator Version 1.0.6 by BuddyDev
BuddyPress Multi Network Version 1.0.2 by Brajesh Singh
BuddyPress Xprofile Custom Field Types Version 1.1.5 by BuddyDev
Classic Editor Version 1.5 by WordPress Contributors
Custom Profile Menu for BuddyPress Version 1.0.2 by Nahid Ferdous Mohit
Paid Memberships Pro Version 2.3.4 by Stranger Studios
Paid Memberships Pro – BuddyPress Add On Version 1.2.5 by Paid Memberships Pro
Paid Memberships Pro – Roles Add On Version 1.2 by Paid Memberships Pro
Premium Starter Templates Version 2.3.1 by Brainstorm Force (Latest version: 2.3.2)
Weaver Xtreme Theme Support Version 4.0.5 by wpweaver
WP Multi-Network Version 2.2.0 by johnjamesjacoby, ddean, BrianLayman, rmccue
WP Super Cache Version 1.7.1 by AutomatticHere are the plugins I’m using on the BuddyBoss site:
BuddyBoss Platform v1.4.6
Contact Form 7 v5.2
LearnDash LMS – Course Grid v1.6.0
LearnDash LMS – WooCommerce Integration v1.8.0
Mailchimp for WooCommerce v2.4.1
Paid Memberships Pro v2.3.4
Paid Memberships Pro – BuddyPress Add On v1.2.5
Paid Memberships Pro – Roles Add On v1.2
LearnDash LMS v3.2.1
WooCommerce v4.3.0
WP Mail SMTP v2.2.1
WP Multi-Network v2.4.0
Duplicator Pro v3.8.9.1
BuddyPress Multi Network v1.0.2Hi RES,
No issues.can you please tell me where did you place the code ? is it in wp-content/plugins/bp-custom.php?
Thank you
BrajeshHi,
I am sorry for the delay.You will need assistance from BuddyBoss support. I am unable to find time to assist you with BuddyBoss and other other plguins.
The above code is for BuddyPress.
Regards
Brajesh
You must be logged in to reply to this topic.