CalcBuilder Forum

calculator only registred user

User bsnline 2017-07-31 17:41:50

Hi,

Plaese suggestion for script to insert in to tab "code", for allowed only registred user to use calculator.
Thank you

Moonsoft support 2017-07-31 21:02:37

Hi,
you have access to all php functions and also to Joomla core classes at your code tab, so you could use the default user object:

$user = JFactory::getUser(); // Get the user object

if ($user->id != 0)
{
// you are logged in
}
else
{
// you are NOT logged in
}


But for the purpouse of restrict the access to calculator form, you have the better option of using default joomla permissions and choose the article or the menu option of the calculator to be accesible only for registered users, at menu options.

Regards

User bsnline 2017-08-02 17:27:04

Hi,
Thank you for reply,
i tried put the script il tab code but not work.

Moonsoft support 2017-08-03 08:56:04

Hi,
the above seems valid php code according to joomla docs, we share the official page where you can check how user object can be recovered and handled:


https://docs.joomla.org/Accessing_the_current_user_object

please note you can also use 'guest' property in order to find out if user is currently logged in. (Check 'Determining Status' section to see the code)

If you have problems with the php coding, remember you can use the default menu settings from joomla in order to restrict the access to individual menus.

Hope this helps

...
Support/development

Perfect for small code changes or to correct any bug at your site

Buy now!
...
Support/development 40 hours

With the peace of mind of having a professional team at your service (20% discount)

Buy now!