Support Forum
Support › MB Frontend Submission › Custom User Register Form - Errors Upon Validation Checks
Hi
I am trying to override the wordpress register form, all works ok except if you don't fill in the user_pass
field and submit the form I receive the following error: Undefined array key "user_pass" in C:\wamp\www\dcplatform\wp-includes\user.php on line 2103
and Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\dcplatform\wp-includes\user.php:2103) in C:\wamp\www\dcplatform\wp-includes\pluggable.php on line 1435
$meta_boxes[] = [
'title' => '',
'type' => 'user',
'storage_type' => 'custom_table',
'table' => $wpdb->prefix . 'dc_users',
'id' => 'dc-user-register',
'context' => 'normal',
'fields' => [
[
'type' => 'text',
'name' => 'First Name', //label for form
'id' => 'first_name', //mysql name (custom table)
'required' => true,
],
[
'type' => 'text',
'name' => 'Last Name', //label for form
'id' => 'last_name', //mysql name (custom table)
'required' => true,
],
[
'name' => 'Email',
'id' => 'user_email', //REQUIRED (default WP field)
'type' => 'email',
'required' => true,
],
[
'id' => 'registered_date', //mysql table col
'type' => 'hidden',
'std' => date('Y-m-d H:i:s'),
],
[
'name' => 'Password',
'id' => 'user_pass', //REQUIRED (default WP field)
'type' => 'dc_password_strength_checker',
'required' => true,
'attributes' => [
'minCharacters' => 8, //min password length
'lowerUpperCase' => true, //contain lower & uppercase
'numbers' => true, //contain numbers
'specialCharacters' => false, //contain special characters
],
],
],
];
I forced the validation to fail and with checks but it does not work as the above errors still display?
if ( 'dc-user-register' !== $config['id'] ) {
return 'test';
}
Hello,
If you don't add a value to the field, it will not be passed to the data that is used to register the user and causes the issue.
I see you use the setting required
for the password field so leaving this field empty isn't possible.
Hi
Yes i am able to submit the form without filling in the required password field. I assumed that the form would fail, but instead i see the PHP error messages. How is this possible? as i have even forced the form to fail and it does not work either.
screen recording
https://drive.google.com/file/d/1I_iBm2FAPmAUyXxzxHMpe4eDTL1PeHgg/view?usp=sharing
thanks
Nick
Hello Nick,
How do you process the form data after submitting it? Do you use your own custom code to do that? Also, I see you are using the custom field type dc_password_strength_checker
, please switch to the type password
of Meta Box and see how it goes.
Hi
The form still works with the wordpress user registration and the custom field still has the id 'user_pass'. So not sure what else is required to perform the check if the password field is left empty? when its required.
Can you please answer my questions?
- How do you process the form data after submitting it?
- What happens if you switch to the type password
of Meta Box?
Thank you.
Hi
I thought I had answered them.
How do you process the form data after submitting it?
I dont do any custom processing, the form works with the default wordpress registration process.
What happens if you switch to the type password of Meta Box?
The same issue persists.
thanks
Also I just use the shortcode with this metabox extension https://docs.metabox.io/extensions/mb-user-profile/
Hello,
Please share your site credentials by submitting this form https://metabox.io/contact/
I will take a look.
Hi Peter
I am working on a project locally and do not have it available online yet. Are you unable to replicate it?
Nick
Yes, I'm not able to replicate the issue on my demo site. Please try to setup an online staging site, replicate the issue there and share the site credentials. I will check this on my end.