Custom Registration Example

Permalink 5 users found helpful
Hello World,

This thread is to answer some questions posed athttp://www.concrete5.org/index.php?cID=27239... and to help anyone else who's interested.

Attached are an example page and an example controller for a registration/signup process. The idea is that if you are trying to do certain things in the registration process that are not what c5 already does, you can make your own registration single page and controller. That way you don't have to hack away at the core and be sorry later. Unless something radical changes in the core, you can happily upgrade your site to a new version of c5 and your custom signup process will still work fine.

In these particular examples, I've made it so that the user only sets their password after they register and confirm. It also only shows them a CAPTCHA if they submit with some spammy elements, like rogue POST values or no HTTP_USER_AGENT, etc. And it subscribes them to a MailChimp list and adds them to some groups in c5. The point is that you can do whatever you want…mine is just an example so you can see how it works.

Another simpler option, of course, would be to tie in with c5 events, such as on_user_add. It's certainly wiser to stick to events if it's just something simple you're trying to do in addition to what c5 already does. But there are times when events don't do all that you need, so that's why I'm posting this. Hope it helps somebody.

Benji
 
Benji replied on at Permalink Best Answer Reply 1 Attachment
Benji
The forum is having some trouble with uploading files…
cyandesigns replied on at Permalink Reply
Thanks Benji. I really appreciate your help.

I'm going to look this over (in detail!) and hopefully it'll help me out.
cyandesigns replied on at Permalink Reply
Actually I do have a question for you...

If I upload these two files, you have so graciously supplied, it should function just as you reported, yes?

Are there any other steps involved?

I'm not using Mailchimp so I wouldn't need that part, but I could play with the add to group portion to see if I can get it to function as I would like.

Thanks again!
Benji replied on at Permalink Reply 1 Attachment
Benji
Well, you would first of all need to not forget to change the filenames to the same things (I had to name them differently so they could coexist in the same .zip folder), i.e. signup.php in the /single_pages folder and signup.php in the /controllers folder … or whatever name you want. If you name them registration.php, then concrete5 will use that file whenever someone visits yoursite.com/index.php/registration instead of the registration.php file in the /concrete/single_pages directory.

You would definitely want to style the markup in the single page with some CSS. I have no idea what kind of a horror it would be without some styling.

There are a couple of places in the controller where I was using my own helper methods -- if you read the comments in the file, you'll see them. Here, I'll attach that class too. You just make a folder in your /helpers folder called 'validation' and then put the attached file in there. It's nothin' special, though.

So, yeah, just delete the MailChimp stuff you don't need and put your group names in the add to group part. You'd also need to work with the confirmation email part to go with your site. That involves making a mail template and putting it in your /mail folder, if you haven't done that before. You can figure out how to do that pretty easily by looking at the files in /concrete/mail/.

Other than that, if you change any of the fields in the single page, like if you decide you don't want a "country" field for instance, then you'll need to adjust the validation at the beginning of the controller so it doesn't require that field (i.e. delete that validation). And then let's say you want to put in your "department" field, so don't forget to add it to the hidden fields in the CAPTCHA state of the single page as well as to the validation in your controller.

It seems kind of silly for you to go to all this trouble when you were just needing to add a user to a selected group upon registration. I hope you get some other mileage out of it though. I think I might start thread asking why the enterGroup method isn't working in the on_user_add event, or did you do that already?
cyandesigns replied on at Permalink Reply
No - I didn't do that already. I don't feel that I have enough of the knowledge behind php to ask such a question...I'm still a bit new to the language and how it functions.

By NO means am I looking for you to do my "dirty work" but I do appreciate everything you've done so far.

I am still searching for some sort of work around so I'll just have to go at it slowly and systematically until I find the right middleground. Who knows, maybe the next release will come out by then with all of this addressed...

Thanks for being a great community member!
jordanlev replied on at Permalink Reply
jordanlev
This is awesome -- thanks!