Jump to content

LoginRegister - Display Registration Form even when already logged it?


Recommended Posts

Hi all. I'm using the LoginRegister module with a Business-to-Business site. Currently, it appears that you can only call up the Registration form if you are not logged in. I don't want just anyone signing up for an account but would like the sales reps to sign up clients for them. As such, I want to password-protect the Registration form so only certain roles can access it.

"Why not just log in to the back-end and create a new user?" you say. I'd like the signup form in the front end because a) this will be the only function the sales reps will use and b) they will often sit with the customer and fill-out the form together. I'd like the interface to match the front end of the site.

Can I enable the Reg form through a hook? Any pointers would be greatly appreciated.

Link to comment
Share on other sites

Yes you can.

I have something similar for a blogging site. Copy/edit/improve here what makes sense to your case...

wire()->addHookBefore('LoginRegister::renderList', function($event) {

    $links = array();
    $defaults = $event->arguments(0);

    if(user()->isLoggedin()) {

        if (user()->hasRole('member')) {

            $links['member-list'] = "<a href='" . $this->wire('pages')->get('/directory/')->url . "'>" . $this->_('Member Directory') . "</a>";
        if (user()->hasRole('author')) {

            $links['blog-admin'] = "<a href='" . $this->wire('pages')->get('/utilities/blog-admin/')->url . "'>" . $this->_('Blog Admin') . "</a>";
        if (user()->hasRole('admin')) {

            $links['back-admin'] = "<a href='" . $this->wire('pages')->get('template=admin')->url . "'>" . $this->_('Page Admin') . "</a>";

    } else {

        if($event->object->allowFeature('register')) {

            $defaults['register']  = "<p>Don't have an account yet? Members can <a href='./?register=1' class='inline'>" . $this->_("register for an account") . "</a></p>";

    $links = array_merge($links, $defaults);

    $event->arguments('items', $links);


  • Like 3
Link to comment
Share on other sites

@strandoo Why don't you create one dedicated page + template for this special use-case?

A page that can only be accessed by the sales reps, and then instead of using the LR module you build your own form and with a few lines of code create your new users via API?

Of course, this has the downside that those new users won't be getting automatically generated confirmation emails. But maybe you don't need that feature in your case?

Link to comment
Share on other sites

@dragan You’re right; given my limited skills that would be easier. I’ve done something like that for a site without the LoginRegister module, but I guess I just wanted to see if I could keep it all in the same package, and learn more about hooks. But whatever gets the job done. Thanks. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...