Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to branch pages


  • mutoha
    Participant

    @mutoha

    Is there a function to branch pages?

    Currently I am supplementing that function with the following code.

    $arr = explode( '/', $_SERVER['REQUEST_URI'] );
    if ( isset($arr[1]) && $arr[1] === 'members' ) :
    
    	if( is_user_logged_in() ) :
    		
    		if( bp_loggedin_user_id() == bp_displayed_user_id() ) :
    		
    			if( ( $arr[3] === '' || $arr[3] === 'activity' || $arr[3] === 'profile' || $arr[3] === 'following' || $arr[3] === 'followers' ) && $arr[4] != 'following' && isset($arr[3]) ) :
    				echo 'hello';
    
    			elseif( $arr[3] === 'forums' ) :
    				echo 'hello';
    
    			elseif( $arr[3] === 'bp-messages' || $arr[3] === 'settings' || $arr[3] === 'notifications' || $arr[3] === 'following' ) :
    				echo 'hello';
    		
    			endif;
    			
    		else:
    			
    			if( ( $arr[3] === '' || $arr[3] === 'activity' || $arr[3] === 'profile' || $arr[3] === 'following' || $arr[3] === 'followers' ) && isset($arr[3]) ) :
    				echo 'hello';
    										
    			elseif( $arr[3] === 'forums' && isset($arr[3]) ) :
    				echo 'hello';
    			
    			endif;	
    			
    		endif;
    
    	else:
    
    		echo 'guest';
    
    	endif;
    	
    endif;	

    But It’s not cool..
    Please inform me if you have a better method to solve the problem than the one previously mentioned.

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

  • Venutius
    Moderator

    @venutius

    You’ve not explained what you are trying to do, presumably you are trying to display a message to the user that changes depending on the page visited. The question is, exactly where on the page you want to display the message.


    mutoha
    Participant

    @mutoha

    That’s right.
    How can I branch condition by page?
    For example, I want to branch like
    if ( is_page( topic ) ) {}
    if ( is_page( activity ) ) {}
    if ( is_page( profile ) ) {}
    if ( is_page( settings ) ) {}


    Venutius
    Moderator

    @venutius

    Do a search in the buddypress files for bp_is_user or bp_is_, bp has a number of functions such as bp_is_user_profile() or bp_is_user_activity, function bp_is_user_profile_edit(), bp_is_group() which confirm if the user is accessing different pages.


    Venutius
    Moderator

    @venutius

    bp_is_blog_page()
    bp_is_my_profile()
    bp_is_home()
    bp_is_front_page()
    bp_is_activity_front_page()
    bp_is_directory()
    bp_is_page($page)
    bp_is_active( $component )
    bp_is_profile_component()
    bp_is_activity_component()
    bp_is_blogs_component()
    bp_is_messages_component()
    bp_is_friends_component()
    bp_is_groups_component()
    bp_is_settings_component()
    bp_is_member()
    bp_is_user_activity()
    bp_is_user_friends_activity()
    bp_is_activity_permalink()
    bp_is_user_profile()
    bp_is_profile_edit()
    bp_is_change_avatar()
    bp_is_user_groups()
    bp_is_group()
    bp_is_group_home()
    bp_is_group_create()
    bp_is_group_admin_page()
    bp_is_group_forum()
    bp_is_group_activity()
    bp_is_group_forum_topic()
    bp_is_group_forum_topic_edit()
    bp_is_group_members()
    bp_is_group_invites()
    bp_is_group_membership_request()
    bp_is_group_leave()
    bp_is_group_single()
    bp_is_user_blogs()
    bp_is_user_recent_posts()
    bp_is_user_recent_commments()
    bp_is_create_blog()
    bp_is_user_friends()
    bp_is_friend_requests()
    bp_is_user_messages()
    bp_is_messages_inbox()
    bp_is_messages_sentbox()
    bp_is_notices()
    bp_is_messages_compose_screen()
    bp_is_single_item()
    bp_is_activation_page()
    bp_is_register_page()

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