Jump to content

IPS4 Hook into pre and post registration

Featured Replies

Posted

First, lets start off by saying I love IPS4. That being said, the documentation and guides available for it are far and few between =(

 

I'm trying to create a plugin to hook into Pre and Post registration

 

The only thing I've found is being able to hook into post registration when it calls to send a verification email, and when the account has been verified(which is not run if no verification is required)

I can't find anything on pre-registration where I can validate a custom field

Just now, Tad Taylor said:

I can't find anything on pre-registration where I can validate a custom field

By pre-registration you mean the registration form, when the user clicks the button to create the account ?

  • Author
Just now, Adriano Faria said:

By pre-registration you mean the registration form, when the user clicks the button to create the account ?

Yes sir!

Which kind of validation you need to do in the profile field?

You can set it to required and use Regular Expression in some cases.

  • Author

I need to make a custom call to validate the information, simply requiring the field won't suffice =/

I'm not sure how to do this with profile fields. Does it have to be a profile field? If you use a text box, for example, you validate it on the form, like that:

			$form->add( new \IPS\Helpers\Form\Text( 'blog_name', $this->id ? $this->_title : NULL, FALSE, array(), function( $value ) {
				if ( \IPS\Request::i()->blog_type === 'member' AND !$value )
				{
					throw new \InvalidArgumentException( 'form_required' );
				}
			}, NULL, NULL, 'blog_name' ) );

That will throw an error and won't accept the registration.

  • Author

That's looking like its the right direction, where would I hook this into though?

Take a look in this plugin. It extends the registration screen to add the birthday:

Instead of using $form->add( new \IPS\Helpers\Form\Custom, you will use $form->add( new \IPS\Helpers\Form\Text and add the validation as the above example.

You don't have to use the _createMember method. You need only if you want to add information.

If you still need to run post-registration code, you can add a member sync plugin to an application and add your code to onCreateAccount() or onValidate() depending on your needs.

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.