Skip to:
Content
Pages
Categories
Search
Top
Bottom

When viewing a profile I want a different tab based on the displayed user role


  • lynnapp
    Participant

    @lynnapp

    Hi,
    I have been using the below code, So when someone clicks on the profile of an association it will redirect to the products tab.
    All is well and I can use the other tabs to navigate around except when I click on the activities tab. It takes me to the products tab users cannot see the associations (role) activity stream.

    I removed this code and it worked fine so it is some where here. I have this in the child-theme/buddypress-nouveau/members/single/home.php page

    WP Version 5.7.2 PHP 7.4.12

    	$displayed_user =  new WP_User( bp_displayed_user_id() );
    
    	if  ( ( in_array( 'associations', $displayed_user->roles, true ))   &&  
    		(strpos($_SERVER['REQUEST_URI'], "my-products") == false)  &&
    		(strpos($_SERVER['REQUEST_URI'], "front") == false)  &&
    		(strpos($_SERVER['REQUEST_URI'], "profile") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "activity") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "friends") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "my-donations") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "notifications") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "messages") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "groups") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "location") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "invite-anyone") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "settings") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "w-my-account") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "store-manager") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "articles") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "media") == false) &&
    		(strpos($_SERVER['REQUEST_URI'], "item-header-content") == false) 
    		) 
     
    	{
     //is assoc and is not already redirected to products or other profile links
    	$currenturl =  $_SERVER['REQUEST_URI'];
        	$urlto = $currenturl."my-products";
    ?>
            <script>
    	window.location.replace("<?php echo($urlto); ?>");
    	</script>
    <?php	
    
      	} else {  //  just load
    ?>
    

    Thank you for helping with this

Viewing 2 replies - 1 through 2 (of 2 total)

  • lynnapp
    Participant

    @lynnapp

    I have done some more research, removing lines and adding them back in. So the problem is that when activity loads it then does a reload which then makes if statement true and goes to my products,

    So where would I find the reloading of activity or how would I add something that would check for this and allow it?

    Might be the theme which is Kleo


    lynnapp
    Participant

    @lynnapp

    More Information.
    If I make the default profile tab “home” then that is the tab that will not load on the associations. Which makes this have something to do with how the default profile tab loads even when called from within the profile.

    Any ideas on how to keep the default for everyone the activity and products for the role of associations

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar