Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I force a login?

Viewing 4 replies - 1 through 4 (of 4 total)
  • @bgrun80

    Participant

    Also, I tried doing:

    /* If not logged in, the user will be redirected to the registration/login page */
    if ( !is_user_logged_in() ) :
    include ‘registration/register.php’;
    else :
    index.php as normal

    but that didn’t work either…

    @modemlooper

    Moderator

    Are you trying to close your sight off to all except logged in users?

    if (!is_user_logged_in() ){
    bp_core_redirect( $bp->root_domain.’/register’ );
    }

    @jalien

    Participant

    There are lots of wordpress plugins that will do this. A simple to use that redirects by role is:
    https://wordpress.org/extend/plugins/peters-login-redirect/

    @bgrun80

    Participant

    Thanks for the quick replies.

    @modemlooper: When I tried your code, it gave me this…
    Warning: Division by zero in C:xampplitehtdocswp-contentthemespartyhookupsindex.php on line 10
    Warning: Cannot modify header information – headers already sent by (output started at C:xampplitehtdocswp-contentthemespartyhookupsindex.php:4) in C:xampplitehtdocswp-includespluggable.php on line 890

    @Jalien: I will give it a shot, but I’d really prefer to use my own code and keep plugins to a minimum

    I tried this and it worked, but I’m wondering if it will break something else or if it’s bad programming practice. Any thoughts?

    if ( !is_user_logged_in() ) :
    global $bp;
    $bp->signup->step = ‘request-details’;
    locate_template( array( ‘registration/register.php’ ), true );
    else :
    index.php as usual

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How do I force a login?’ is closed to new replies.
Skip to toolbar