Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Tad Taylor Posted May 2, 2016 Posted May 2, 2016 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
Adriano Faria Posted May 2, 2016 Posted May 2, 2016 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 ?
Tad Taylor Posted May 2, 2016 Author Posted May 2, 2016 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!
Adriano Faria Posted May 2, 2016 Posted May 2, 2016 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.
Tad Taylor Posted May 2, 2016 Author Posted May 2, 2016 I need to make a custom call to validate the information, simply requiring the field won't suffice =/
Adriano Faria Posted May 2, 2016 Posted May 2, 2016 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.
Tad Taylor Posted May 2, 2016 Author Posted May 2, 2016 That's looking like its the right direction, where would I hook this into though?
Adriano Faria Posted May 2, 2016 Posted May 2, 2016 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.
bfarber Posted May 3, 2016 Posted May 3, 2016 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.