BuddyDev

Search

[Resolved] Site Logo Redirect: Logged Out Users

  • Participant
    Level: Initiated
    Posts: 2
    Andrew on #37021

    Thanks for your time. I’m already using this code to create different “homepages” for logged in and logged out users and it’s working great:

    /**
    * When a user is logged in, tell WordPress to use ‘page’ on front page of the site
    * @param string $value
    *
    * @return string
    */
    function buddydev_set_page_as_front_for_loggedin_user( $value ) {
    if ( is_user_logged_in() ) {
    $value = ‘page’;//page is set as front page
    }

    return $value;
    }
    add_filter( ‘pre_option_show_on_front’, ‘buddydev_set_page_as_front_for_loggedin_user’ );

    /**
    * For logged in users, set our static page to act as home page
    *
    * @param $value
    *
    * @return int
    */
    function buddydev_set_context_based_page_on_front( $value ) {

    if( ! is_user_logged_in() ) {
    return $value;
    }

    //for logged in user, use page id 9
    return 1231;//change with your own page id.
    }
    add_filter( ‘pre_option_page_on_front’, ‘buddydev_set_context_based_page_on_front’ );

    However, when a logged out user clicks on my site logo, the code sends the user to page 1231 which only logged in users can see.

    I want to send logged out users to a different page when they click the site logo.

    Is this possible?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2934
    Ravi on #37032

    Hello Andrew,

    Thank you for posting. For filtering the logo link you can use the following filter:

    
    get_custom_logo
    
    

    Please give it a shot.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 2
    Andrew on #37053

    Thanks Yogi. And thanks for the code I stated I’m already using. I got it from you guys and it’s working like a charm.

    As for this situation, what would the code look like using the get_custom_logo? I don’t know how to write it.

  • Participant
    Level: Initiated
    Posts: 2
    Andrew on #37076

    Hey Yogi. Ravi sent me some code but it didn’t work. I’m sure it’s something that I’m doing wrong on my end. I could give login credentials if that would be more of a help.

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #37091

    Hi Andrew,
    Thank you for the reply.

    The simple way will be to visit Dashboard->Settings->Reading and set the page as Home page that you want to be visible to the logged out user.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: resolved