Elxis CMS Forum

Support => General => Topic started by: rentasite on November 23, 2017, 00:36:45

Title: User Registration on Locked Site - [SOLVED]
Post by: rentasite on November 23, 2017, 00:36:45
Hi. I'm developing a site that will work as locked (Website status: Online for users). I have set "User Registration: Yes" and the "Account activation: Manual by Administrator".

The purpose is the visitor to face the offline page, but to be able to Register for a user account on the site. And the admin to manually approve the registration.

How can this be done? Am i missing something? The offline page just shows the username/password fields. No ability to register.


* I'm using IOSX - Extra pages pack for Elxis Templates
Title: Re: User Registration on Locked Site
Post by: datahell on November 23, 2017, 20:24:56
This is opposite to the idea of the "Users only" site. However you can do it!

Here are 2 solutions:
1. (the hard solution) Develop a special exit page that will include user registration feature. (I have developed a similar - not as you want- solution for LDAP/Gmail registration on locked sites - See IOSX exit pages (https://www.elxis.net/edc/templates/131.html)
2. (the easy solution) Make your site available to public! Open your template's index.php and set up a redirection to component user for non logged-in users.

if ($elxis->user()->uid == 0) {
     if (eFactory::getURI()->getComponent() != 'user') {
        $link = $elxis->makeURL('user:register.html', '', true, false);
        $elxis->redirect($link);
    }
}

Explanation: If visitor is not an Elxis user and he doesn't see component user pages then redirect him to registration page.

Tip: As your site will be opened to visitors (even if they will only see component user) they will be able to see your menus, modules, etc. You can change the access level of these items to users only (level 2 or greater) so visitors will see almost nothing except the registration form.
Title: Re: User Registration on Locked Site
Post by: rentasite on November 23, 2017, 20:49:57

Yes i have seen the LDAP/Gmail registration on locked sites solution.

I will proceed with the 2nd solution.


Thanks :)
Title: Re: User Registration on Locked Site
Post by: rentasite on November 27, 2017, 22:02:55

Getting back to say that the 2nd solution works perfect!  :D

Thanks Yianni
Title: Re: User Registration on Locked Site - [SOLVED]
Post by: datahell on November 27, 2017, 22:06:34
Good!  :)
Title: Re: User Registration on Locked Site - [SOLVED]
Post by: komang on February 12, 2018, 03:12:36
Hi Datahell,

Can I use the code at a specific page? For example, if non-register users visit this page (https://finteku.com/fintek-app/) so they will be redirected to register page.


if ($elxis->user()->uid == 0) {
     if (eFactory::getURI()->getComponent() != 'user') {
        $link = $elxis->makeURL('user:register.html', '', true, false);
        $elxis->redirect($link);
    }
}

Thank you
Title: Re: User Registration on Locked Site - [SOLVED]
Post by: datahell on February 12, 2018, 23:02:56
Wrap the code I already wrote with a check for the desired category ID.

if (defined('ELXIS_CATID') && (ELXIS_CATID == X)) {
     ...code here...
}

Replace X with the id of the category you want.

To do it for article use ELXIS_ARTID instead.
Title: Re: User Registration on Locked Site - [SOLVED]
Post by: komang on February 13, 2018, 11:27:36
Hi Datahell,

It works! Anyway, does it work for a component as well? For example: https://finteku.com/topik-baru/ this link is menu to MyContent Component, I want to redirect non-register users who access that page to register page.

Thanks in advance

Regards

Komang
Title: Re: User Registration on Locked Site - [SOLVED]
Post by: datahell on February 13, 2018, 14:53:58
Yes, it works for a component too :D
In this case wrap the code with this :

if (eFactory::getURI()->getComponent() == 'X') {
   ... code here ...
}

Where X lowercase component name without "com_" prefix. In your case mycontent

if (eFactory::getURI()->getComponent() == 'mycontent') {
   ... code here ...
}
Title: Re: User Registration on Locked Site - [SOLVED]
Post by: komang on February 13, 2018, 17:31:14
Thank you so much Datahell..it works.

You know, I tried to guess the code to do this. On your previous post, you said ELXIS_CATID for category and ELXIS_ARTID for articles, so I tried ELXIS_COMID for components... lol  :)
Title: Re: User Registration on Locked Site - [SOLVED]
Post by: datahell on February 13, 2018, 19:00:17
It was a good guess but, unfortunately, does not work like this ;D
Title: Re: User Registration on Locked Site - [SOLVED]
Post by: komang on February 14, 2018, 00:02:15
 ;D

again, thank you Datahell