Skip to:
Content
Pages
Categories
Search
Top
Bottom

Help with homepage redirect to Profile Page


  • soloacademy
    Participant

    @soloacademy

    I want my users to be redirected from my homepage to their profile page if they are already logged into their account. This redirect will be on the homepage itself, basically once a user is logged into their account they will never be able to see the home page again. If they click on the ‘home’ tab it will take them to their profile page. Here is what I think the code should look similar to…

    if ($loggedin == "true" ) {
        //redirect to buddypress profile page
    } else { 
       // dont do anything
    }
    

    I have no clue if $loggedin is correct or if this is even the right format. I would really appreciate any help on this topic so I can move on with my site 🙂 Hopefully I have give you enough information to understand what i’m trying to do.

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

  • bp-help
    Participant

    @bphelp


    soloacademy
    Participant

    @soloacademy

    I’m still a little confused. Is that code only for when the user logs in? I want it so that anytime the user goes to my homepage if they are logged in it will redirect them to their profile page. So I will be putting this code into the homepage template
    Should it look like this?

    if ( !is_user_logged_in() && ( $bp_unfiltered_uri[0] != $bphelp_my_front_page ) )
    header( 'Location: http://www.yoursite.com/' ) ; );
    
    elseif(none);
    
    }
    

    Should $bphelp_my_front_page be replace with ‘True’ or ‘Yes’?
    Thanks


    Henry
    Member

    @henrywright-1

    @bphelp nice new blog! looking forward to hearing some tips and tricks…


    soloacademy
    Participant

    @soloacademy

    @bphelp opps I forgot to mention you in the last comment. Please take a look at it above. Thanks


    Henry
    Member

    @henrywright-1

    @soloacademy

    You don’t need to put any code in your homepage template. @bphelp’s code goes into your bp-custom.php file.

    I am using a slightly different method. Copy and paste this into your theme’s functions.php file.

    //redirect logged in users away from homepage to their profile page
    function bp_homepage_to_profile() {
    	global $bp;
    	
    	if(is_user_logged_in() && bp_is_front_page()) {
    		wp_redirect( $bp->loggedin_user->domain );
    	}
    		
    }
    
    add_action('wp','bp_homepage_to_profile');

    bp-help
    Participant

    @bphelp

    @henrywright-1
    Thanks, I look forward to adding more tips and tricks in the future.
    🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Help with homepage redirect to Profile Page’ is closed to new replies.
Skip to toolbar