Reply To: Popup not working in WP

Home Forums Quform WordPress Popup not working in WP Reply To: Popup not working in WP

#31519
felixvelarde
Participant

Thanks Ally – I got it working in the end. It was my fault, conflict with a separate JS.

I am struggling with getting the User Registration to add the user role to the newly registered user – I’m using the code you suggested but while FirstName and LastName are updating, Role isn’t. Can you show me where I’ve got it wrong please? Much appreciated!

This is the page:
https://2y3x.com/videos/lockdown22052020/

add_filter(‘quform_element_valid_7_4’, function ($valid, $value, Quform_Element_Field $element) {
if (username_exists($value)) {
$element->addError(‘This username is already taken’);
$valid = false;
}

return $valid;
}, 10, 3);

add_filter(‘quform_element_valid_7_7’, function ($valid, $value, Quform_Element_Field $element) {
if (email_exists($value)) {
$element->addError(‘This email is already registered’);
$valid = false;
}

return $valid;
}, 10, 3);

add_action(‘quform_post_process_7’, function (array $result, Quform_Form $form) {
$username = $form->getValueText(‘quform_7_4’);
$email = $form->getValueText(‘quform_7_7’);
$password = $form->getValueText(‘quform_7_5’);

$userId = wp_insert_user(array(
‘user_login’ => $username,
‘user_pass’ => $password,
‘user_email’ => $email
));
update_user_meta($userId, ‘first_name’, $form->getValueText(‘quform_7_3’));
update_user_meta($userId, ‘last_name’, $form->getValueText(‘quform_7_9’));
update_user_meta($userId, ‘role’, $form->getValueText(‘quform_7_8’));
wp_signon(array(
‘user_login’ => $username,
‘user_password’ => $password,
‘remember’ => true
));
return $result;
}, 10, 2);

Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy