2016-04-12, 17:41:37
Hello,
creating a password protected page by Frontainer is easier than you might think:
Let's say that your have a secret page with the slug "private" with some subpages and you would like to restrict access to for not-logged in users. So all you have to do is to add following code lines to the template.php file, right after the
"$content = frontainer_get_content()" function call:
If you don't really want to use the Frontainer's standard "account" page and after a successful login the user should be redirected to a private page you created, you could just add a redirect line to the Frontier’s loggedin.php file at the end of the "build_user_area()" function:
creating a password protected page by Frontainer is easier than you might think:
Let's say that your have a secret page with the slug "private" with some subpages and you would like to restrict access to for not-logged in users. So all you have to do is to add following code lines to the template.php file, right after the
"$content = frontainer_get_content()" function call:
PHP Code:
// get the current page slug
$slug = get_page_slug(false);
// and the page parent slug
$parent = get_parent(false);
if($slug == 'private' || $parent == 'private')
{
// The user is not logged in
if(empty($_SESSION['loggedin'])) {
// Redirect to the login page
header('Location: ' . htmlspecialchars($SITEURL.'login/'));
exit();
}
}
If you don't really want to use the Frontainer's standard "account" page and after a successful login the user should be redirected to a private page you created, you could just add a redirect line to the Frontier’s loggedin.php file at the end of the "build_user_area()" function:
PHP Code:
header('Location: ' . htmlspecialchars($manager->getSiteUrl().'/private/'));
exit();