This topic has 7 replies, 4 voices, and was last updated 8 years by FD.

  • Author
  • #70107
     Kosiii
    Participant

    Im wondering how can I not show the front page after the user has logged in.
    Ive created frontpage, where I want to hide the top menu, which means users will click on the log in button. After they have done that and logged in, I want them to not see this front page anymore.

    Any tips about how to achieve this with out installing extra plugins as the theme is heavy enough.

    #70193
     sharmstr
    Moderator

    You can use this to redirect them wherever you want https://bphelpblog.wordpress.com/2013/06/22/buddypress-redirect-to-profile-trick-using-a-landing-page/

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #85914
     Jessica
    Participant

    Hello! I am trying to accomplish the exact same thing with my website, but no matter what I do (please see attached image and code below for details), I’m getting redirected to the home page after logging in.

    I’m testing it out with these three accounts/roles:

    1. My Super Admin account (this gets redirected to the Dashboard as intended)
    2. My Administrator account via Facebook login (this gets redirected to the home page, i.e. http://www.mydomain.com)
    3. My Subscriber account via normal login (this also gets redirected to the home page)

    I might be missing something quite obvious, but I’m out of options and would like to have a fresh pair of eyes look at the problem… thank you in advance!

    Code for bp-custom.php with my little notes here and there.

    COPY CODE
    <?php
    
    /* Enable BuddyPress URL format www.localpathfinders.com/username */
    define ( 'BP_ENABLE_ROOT_PROFILES', true );
    
    /* Redirect to profile page after login */
    add_filter( 'login_redirect', 'bp_login_redirect_to_profile' );
    //  The return parameter does not have to be named $redirect_to for this function to work!
    function bp_login_redirect_to_profile( $redirect_url ) {
    
      // Redirect Super Admins and Administrators to backend Dashboard
      // THIS WORKS! <3
      if ( current_user_can( 'Super Admin' || 'Administrator' ) ) {
        $redirect_url = get_dashboard_url();
        return $redirect_url;
      }
      
      // Redirect everyone else to profile page
      // THIS DOES NOT WORK! </3
      else {
        $redirect_url = 'https://www.google.com'; // This does not redirect to Google, either!
        return $redirect_url;
        
        //  List of $redirect_url that did not redirect to profile page with normal login and Facebook login:
        //      get_option('home') . '/' . bp_core_get_username( bp_loggedin_user_id() );
        //      get_home_url() . '/' . bp_core_get_username( bp_loggedin_user_id() );
        //      home_url() . '/' . bp_core_get_username( bp_loggedin_user_id() );
        
        //      bp_loggedin_user_domain();
        //      bp_loggedin_user_domain($user->ID);
        //      bp_core_get_userlink( bp_loggedin_user_id() );
        //      bp_loggedin_user_domain( bp_loggedin_user_id() );
        
      }
    }
    
    /* Redirect to home page after logout */
    add_action('wp_logout','bp_logout_redirect_to_home');
    function bp_logout_redirect_to_home() {
      wp_redirect( home_url() );
      exit();
    }
    ?>
    Attachments:
    You must be logged in to view attached files.
    #85922
     sharmstr
    Moderator

    Use peters login redirect plugin. You can redirect based on role

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #85931
     Jessica
    Participant

    I prefer not to use a plugin because extra plugins tend to bog down the speed, and though I’ve tried to use a variety of caching plugins to avoid this, some are incompatible with vital features of KLEO, as I’ve mentioned in this thread regarding W3 Total Cache.

    Furthermore, I do not want to clutter up the Dashboard, since it is already quite confusing with the numerous plugins that come with KLEO/otherwise necessary to manage WooCommerce/BuddyPress.

    Is there perhaps an obvious error that I’m missing?
    Or is this if loop too difficult to review?

    #86503
     Kosiii
    Participant

    Did you solve this in a different way @localpathfinders ??

    #87060
     Jessica
    Participant

    No, not yet. I will post again with a solution, if I find one.
    In the meantime, I have not yet received a viable response from 7th Queen Support.

    #107290
     FD
    Participant

    Hi @localpathfinders

    We are using this function to redirect the users away from the front page after login.
    This function also “hides” the front page while the user is logged in.

    COPY CODE
    
    add_action('wp', 'check_redirect_page');
    
    function check_redirect_page() {
        if (is_user_logged_in() && is_page( REPLACE_WITH_FRONTPAGE_PAGE_ID )) {
        wp_redirect( get_permalink( REPLACE_WITH_PAGE_ID_OF_THE_PAGE_YOU_WANT_TO_BE_REDIRECTED_TO ));
        exit;
        }
    }
    
Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?