• Resolved ryandesigned

    (@ryandesigned)


    Hello!

    I am using this snippet provided by you to force BP displayed user, instead of user logged in.

    ————-

    `function my_prefix_replace_logged_in_user_by_buddypress_displayed_user( $out, $pairs, $atts ) {
    // Just override user_id if current_user is set to yes and if we are on an BuddyPress user profile
    if( bp_displayed_user_id() !== 0 && isset( $atts[‘current_user’] ) && $atts[‘current_user’] === ‘yes’ ) {
    $out[‘user_id’] = bp_displayed_user_id();
    // Force current user to “no” to prevent being overwritten after
    $out[‘current_user’] = ‘no’;
    }
    return $out;
    }

    // Hook for [gamipress_achievements] shortcode and GamiPress: Achievements widget
    add_filter( ‘shortcode_atts_gamipress_achievements’, ‘my_prefix_replace_logged_in_user_by_buddypress_displayed_user’, 10, 3 );
    // Hook for [gamipress_points] shortcode and GamiPress: User Points widget
    add_filter( ‘shortcode_atts_gamipress_points’, ‘my_prefix_replace_logged_in_user_by_buddypress_displayed_user’, 10, 3 );
    // Hook for [gamipress_user_points] shortcode and GamiPress: User Points widget
    add_filter( ‘shortcode_atts_gamipress_user_points’, ‘my_prefix_replace_logged_in_user_by_buddypress_displayed_user’, 10, 3 );
    add_filter( ‘shortcode_atts_bpps_profile_avatar’, ‘my_prefix_replace_logged_in_user_by_buddypress_displayed_user’, 10, 3 );
    add_filter( ‘shortcode_atts_bpps_profile_user_name’, ‘my_prefix_replace_logged_in_user_by_buddypress_displayed_user’, 10, 3 );
    add_filter( ‘shortcode_atts_bpps_profile_displayname’, ‘my_prefix_replace_logged_in_user_by_buddypress_displayed_user’, 10, 3 );

    It is working great for most shortcodes, except it won’t work for the for [bpps_profile_user_name] or [bpps_profile_displayname] shortcodes?

    Any idea why is wont work for those in particular?

    Thanks!

    • This topic was modified 2 years, 9 months ago by ryandesigned.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @ryandesigned !

    I would be more than happy to assist you today.

    Adding this snippet, the only thing you have to do is to set the widget marking the current user as yes.
    This way the snippet will automatically make the shortcodes, blocks or widgets in the user area with current_user=”yes” work with the user ID shown in BuddyBoss/Press.

    Hope it helps!

    Thread Starter ryandesigned

    (@ryandesigned)

    Thanks… I understand that.

    When I use:

    [bpps_profile_displayname current_user=”yes”]

    it still only shows the display name of the logged in user.

    However for example…when I use

    [bpps_profile_avatar current_user=”yes”]

    it correctly displays and forces the displayed user avatar

    I’m not sure why it works with one shortcode and not the other!

    Thanks

    Hi @ryandesigned !

    These shortcodes do not come from GamiPress so you have to contact the plugin author who made these shortcodes, as our snippet only works for GamiPress shortcodes/widgets.

    Hope it helps!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Force to use BuddyPress displayed user instead of user logged in’ is closed to new replies.