Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Redirect if user is already logged in

  • @trevorn

    Participant

    I am trying to redirect users that have already logged in to a different page if they go to my main/home page on my site using this code:

    function bp_help_redirect_to_profile(){
    global $bp;

    if( is_user_logged_in() && bp_is_front_page() )
    bp_core_redirect( get_option(‘home’) . ‘/members/’ . bp_core_get_username( bp_loggedin_user_id() ) . ‘/profile’ );

    }

    add_action( ‘get_header’, ‘bp_help_redirect_to_profile’,1);

    As the code is now, it sends logged in users trying to get to the front page to their member page, but I would like to change this. I have replaced

    bp_core_redirect( get_option(‘home’) . ‘/members/’ . bp_core_get_username( bp_loggedin_user_id() ) . ‘/profile’ )

    with

    bp_core_redirect( get_option(‘home’) . ‘/new’)

    but get an error every time

    If someone could point me in the right direction as how to direct logged in users to mysite.com/new instead of their member profile, that would be greatly appreciated, thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • @trevorn

    Participant

    Now

    bp_core_redirect( get_option(‘home’) . ‘/members/’ )

    works and sends it to the overall members page.

    My question is, since those two pages (members and members profile) are BuddyPress pages, is that why it works on those two pages, but since /new/ is not a buddypress page, it redirect to that?

    @henrywright

    Moderator

    Try bp_core_redirect( bp_get_root_domain() . '/new' );

    Change new to whatever you like.

    @trevorn

    Participant

    You fantastic fantastic programmer, works like a charm, thanks sooo much. I was going crazy with this. Thanks again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Redirect if user is already logged in’ is closed to new replies.
Skip to toolbar