PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Redirect logic

  1. I have registration form and few pages with content. When people want to see one of these pages, they need to register first ( I use GF and registration extension ) and after they filled out all the fields - they should go to whatever page they clicked on. So, basically, registration is a gate. How to set up this logic with query string or something else ??

    thanks

    Posted 9 years ago on Sunday September 9, 2012 | Permalink
  2. So, you're trying to prevent access to certain pages until the visitor is registered? To do that, you will need to modify the theme's header file to say "if user is not logged in, send them to register first, and then redirect them back to the page they were trying to get to after they register." Does that solve the problem? If so, I've done this with a custom page template. This is the beginning of it:

    [php]
    /*
    Template Name: Must log in
    */
    if(!is_user_logged_in()) {
        $siteurl = get_bloginfo('url');
        $request = $_SERVER['REQUEST_URI'];
        $redirect = urlencode($request);
        header("Location: $siteurl/wp-login.php?redirect_to=$redirect");
        exit;
    }
    get_header(); ?>

    After that, the rest of your page template. Just add this to the top. This will require the user to log in first, before being directed back to the page where they were headed in the first place.

    Posted 9 years ago on Sunday September 9, 2012 | Permalink

This topic has been resolved and has been closed to new replies.