Moonsoft Software Solutions

calculator only registred user

Started 31 Jul 2017 · 3 replies

  1. bsnline
    Hi,

    Plaese suggestion for script to insert in to tab "code", for allowed only registred user to use calculator.
    Thank you
  2. Moonsoft support
    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
  3. bsnline
    Hi,
    Thank you for reply,
    i tried put the script il tab code but not work.
  4. Moonsoft support
    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

Still stuck?

Customers with an active license can open a support ticket.

Log in to open a ticket