• Resolved islp

    (@islp)


    Hello, I used your plugin mainly because it automatically redirects users to home page when they log from the login area.

    Problem is I had another requirement and I added the following lines to single.php:

    if(!is_user_logged_in()){
    wp_safe_redirect(wp_login_url(get_post_permalink()));
    exit();}else{get_header();}

    If I deactivete your plugin, this perfectly works and the user is redirected to the standard login page and, afterwards, to the “private” content he was trying to access.

    If your plugin is active, after user logs, he goes directly to the home page.

    Is there any way to have both functionalities? What I need is basicly this:

    I want to restrict the access of some areas of my WordPress blog only to logged in users. In particular, I want to restrict ALL the posts and SOME pages: when a non-logged-in user tries to access the protected content, he should be redirected to the standard login page and, once logged in, he should be redirected to the content he was previously tried to access.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Matt Biscay

    (@skyminds)

    Hi islp,

    The correct way to do it would be to put your if statement around the_content() in your template file.

    Something along these lines :

    // user not logged in : display login link
    if( !is_user_logged_in() ) :?>
    <a href="<?php echo wp_login_url( get_permalink() ); ?>">Login to view content</a>
    <?php
    else: // user is logged in, display content
    the_content();
    endif;
    Thread Starter islp

    (@islp)

    This is ok from a dev perspective but, as a user, I prefer redirection to the login area (and back to the content), not another link to click

    Plugin Author Matt Biscay

    (@skyminds)

    How do you login to your login area ? Do you click on a link ? If so, just append the ?redirect_to=/wp-admin/ variable to your login link and you can do away with the plugin.

    Thread Starter islp

    (@islp)

    Matt, in general, right now, I need the following behavior:

    1. from the home, when a user clicks the login link, once logged in, he should be redirected to the home;

    2. from the home page, when a user clicks an admin link, he should access the admin area;

    Thread Starter islp

    (@islp)

    Anyway, the redirect_to suggestion works, thank you very much 🙂

    Plugin Author Matt Biscay

    (@skyminds)

    You’re welcome – don’t forget to rate the plugin 🙂

    Thread Starter islp

    (@islp)

    Ok, meantime thanks for you patience and kindness

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

The topic ‘Redirect(s)’ is closed to new replies.