• Welcome to WooUSEFUL by PHPVIBE . Please log in.

How to restrict visitors to login first to access the site

Started by HPR,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

HPRTopic starter

Hello Mario and forum members
As i seen vibe have some new updates
i want vibe for my personal project
i have following requirement....

i want user to login first to surf the site,to watch the videos to comment etc.i mean for anything visitor must login first.
when someone clicked on link of vibe video they must go through login page .
No one should be able to see anything inside the website without logging in.
Also manual registration required

if this possible with vibe what changes this required?
anyone can help with this?
Thank you
  •  

Marius

Hi


if (!is_user()) { 
//show something to guests
} else {
//show something else to users
}

You can use this in index.php and load a different component.

https://github.com/PHPVibe/PHPVibe/blob/master/index.php

for example replace :

$router->map('/', 'home', array('methods' => 'GET', 'filters' => array('id' => '(\d+)')));

with

if (!is_user()) { 
$router->map('/', 'guesthome', array('methods' => 'GET', 'filters' => array('id' => '(\d+)')));
} else {
$router->map('/', 'home', array('methods' => 'GET', 'filters' => array('id' => '(\d+)')));
}

and then create your guesthome.route.php in /views

you can clone https://github.com/PHPVibe/PHPVibe/blob/master/views/home.route.php and change

include_once(TPL.'/home.php');

to

include_once(TPL.'/guesthome.php');

and you'll need to build that guesthome.php in the theme folder similar to how home is built, but with your custom content for guests https://github.com/PHPVibe/PHPVibe/blob/master/themes/main/home.php
If this helped, consider buying me a coffee.
20 years coding, tweaking, building in PHP. Still creating!
  •  

HPRTopic starter

Thanks Mario for explanation i ll check it asap ^-^
  •  

Similar topics (7)