Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted May 2, 20168 yr 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
May 2, 20168 yr 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 ?
May 2, 20168 yr 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!
May 2, 20168 yr 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.
May 2, 20168 yr Author I need to make a custom call to validate the information, simply requiring the field won't suffice =/
May 2, 20168 yr 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.
May 2, 20168 yr Author That's looking like its the right direction, where would I hook this into though?
May 2, 20168 yr 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.
May 3, 20168 yr 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.