Need Variable Used By UM for Member Directory
-
I’m running UM and using the Member Directory functionality. I also use the Gamipress plug in. Gamipress allows me to award points for users doing various things. It supported the ability to display the points a user has accumulated. But, as it’s deployed, it defaults to the currently logged in user when displaying those points.
When my users log into my site and go to the Member Directory pages to view users, and click on their profile, they see their points. But if they click on a different member (which I allow), they see the different member but see their points displayed on the page, rather than the point the different member has accumulated.
I reached out to Gamipress and they said they had an integration with BuddyPress, but not UM. They did provide the code snippet that resolves my issue if I was using BuddyPress. That code is below…
function my_prfx_rplc_log_in_usr_wth_ultmem_displ_usr( $out, $pairs, $atts ) { // Just override user_id if current_user is set to yes and if we are on an Ultimate User profile // Need to replace bp_displayed_user_id() with Ultimate User variable if( bp_displayed_user_id() !== 0 && isset( $atts['current_user'] ) && $atts['current_user'] === 'yes' ) { // Force current user to "no" to prevent being overwritten after $out['current_user'] = 'no'; $out['user_id'] = bp_displayed_user_id(); } return $out; } // Hook for [gamipress_points] shortcode and GamiPress: Points widget add_filter( 'shortcode_atts_gamipress_points', 'my_prfx_rplc_log_in_usr_wth_ultmem_displ_usr', 10, 3 ); // Hook for [gamipress_user_points] shortcode and GamiPress: User Points widget add_filter( 'shortcode_atts_gamipress_user_points', 'my_prfx_rplc_log_in_usr_wth_ultmem_displ_usr', 10, 3 );
When I read the code it’s clear that they’re checking the function that returns the BuddyPress user ID (bp_displayed_user_id()) and then overriding the standard logged in user with that user id which then returns the accumulated points for each person in the Member List array.
So, I’ve been digging thru the UM code to fine the code that builds the Member Directory list so I can find the User ID that is used in the list (rather than the currently logged in user ID). But I’m not finding it.
So, does anyone know what Ultimate User code is being used (or overridden) to build the Member List page that is displayed? And what UM function or variable I can replace the bp_displayed_user_id() function with to get the correct result? If I can find that variable I can use the BuddyPress code integration, replace the function they use with the UM function, and update the Functions code block in my theme, and then hopefully things work.
- The topic ‘Need Variable Used By UM for Member Directory’ is closed to new replies.