Hi Brajesh,
I don’t have any reply from you…
Can you help me for this ?
Thanks a lot,
JossHi Joss,
I am sorry, I am looking for this ID
https://i.imgur.com/LeiiJ3f.pngI will need it to assist you. You mentioned the lables for membership. Can you please tell me the numeric ids?
Thank you
BrajeshHi Brajesh,
I’m sorry, I don’t have any email notification for your reply…
The ID is number 2.
Thank you very much for your help !
JossHi Joss,
Thank you.Please use the updated code as
function buddydev_show_pmpro_membership_level_in_dir() { if ( ! bp_is_members_directory() ) { return; } // for the logged in user. $level = pmpro_getMembershipLevelForUser( bp_get_member_user_id() ); if ( ! $level || $level->id != 2 ) { return; } echo '<div class="bp-member-xprofile-custom-field bp-member-level">' . $level->name . '</div>'; } add_action( 'gwangi_buddypress_member_xprofile_custom_fields', 'buddydev_show_pmpro_membership_level_in_dir', 10 );
Note the small change from earlier is this
if ( ! $level || $level->id != 2 ) { return; }
Hope this helps.
Regards
BrajeshYou are the BEST Brajesh !!
Thank you very much for your help !
Just a last question : if I want to display one more level, how can I do this ?
Thank you for the kind words Joss.
We can modify the above code like this
function buddydev_show_pmpro_membership_level_in_dir() { if ( ! bp_is_members_directory() ) { return; } // for the logged in user. $level = pmpro_getMembershipLevelForUser( bp_get_member_user_id() ); // please update with visible level ids. $visible_level_ids = array( 1, 2 ); if ( ! $level || ! in_array( $level->id, $visible_level_ids ) ) { return; } echo '<div class="bp-member-xprofile-custom-field bp-member-level">' . $level->name . '</div>'; } add_action( 'gwangi_buddypress_member_xprofile_custom_fields', 'buddydev_show_pmpro_membership_level_in_dir', 10 );
Please update the visible level ids with actual ids.
Let me know if it works for you or not?
Regards
BrajeshThnks thanks thanks Brajesh !!
I should really learn PHP code.
Thank you for all your help,
Best,
JossYou are welcome Joss.
Learning is always beneficial 🙂
Best regards
Brajesh
The topic ‘ [Resolved] Multiple Member Types in same directory’ is closed to new replies.