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 12 years ago on Sunday September 9, 2012 |
Permalink