BuddyDev

Search

Redirect BP profile page for certain user roles

  • Participant
    Level: Initiated
    Posts: 2
    Isabel Pinhel on #24788

    Hi there,

    Currently Buddypress generates a profile page for each user. In my setting (a directory website) this only makes sense for users with role “customer” because other user roles would have submitted a listing. These listing owners essentially have duplicated presence in the website, which does not make sense.

    I am currently handling this process manually with Redirection plugin (https://wordpress.org/plugins/redirection/) where I laboriously create a redirection for each member that owns a listing. If the process could be automated then the redirection would be as follows for listing owner roles:

    source url: https://example.com/members/(.*)
    target url: https://example.com/explore/$1

    Is there a way to redirect buddypress profile pages for listing owner user roles? I tried using the code suggested here (https://buddydev.com/support/forums/topic/hide-multiple-user-types-from-memberprofile-page/) but had no luck. Please could you help?

    Many thanks,
    Isabel

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #24798

    Hi Isabel,
    Welcome to BuddyDev forums.

    Thank you for the question. Please help understand a few thing and I will assist. It should be easily doable.

    1. Do you want to redirect from BuddyPress profile to their listing profile or from listing profile to BuddyPress profile?

    2. Are you using any plugin for the listing? If yes, which one.

    Please let me know and I will assist.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 2
    Isabel Pinhel on #24810

    Hi Brajesh,

    1. I want to redirect from BuddyPress profile to their listing profile (but only for specific user roles)
    2. I am using a theme (MyListing) for the listings

    Thanks so much for your help!!

    Isabel

  • Participant
    Level: Initiated
    Posts: 2
    Isabel Pinhel on #25166

    Hi,

    Just following up on this query – any news?

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #25181

    Hi Isabel,
    I am sorry, I am not familiar with your theme, so unable to provide an exact answer.

    I need to know how to determine the listing profile of a user if id or username is given.

    I ma posting a sample code in which redirection is commented, Please feel free to adapt it based on how the listing works on your site.

    
    
    add_action( 'bp_template_redirect', function () {
    	if ( ! bp_is_user() ) { // replace with bp_is_my_profile() to only do it for own profie.e
    		return;//
    	}
    	// Use the id or dimain
    	// bp_displayed_user_id();
    	// bp_displayed_user_username();
    	// where do you want to redirect.
    	// $url = '';
    
    	// bp_core_redirect( $url );
    } );
    
    

    Hope that helps.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved