Update user meta without email

Users on my website, register without email. I use the Digits plugin that let users to register with their phone number without email.

I have created a form with two simple fields, first name and last name. I also created a feed in the form’s registration setting and I hope to update these 2 fields for every user that submit the form.

This form works fine for users that have an email address. But, Unfortunately, it does not work for users without email.

Is there a way to eliminate email checking?

I wonder if you setup a default value email which would populate a hidden email field if this would allow you to register users via the user registration add on.

Since users are registered to Wordpress I’m not sure if you can find a way to overcome the duplicate email issue but perhaps Wordpress has a plugin for this.

I have tried using a default value for the email field. But it did not work.
Registration add-on does not let to update any user without email or to use a duplicate email address.

There is a article about Ignoring duplicate email address in the add-on documentation, but I can’t figure out how to use it.

Looks like you need to add two snippets.

add_filter(         'gform_user_registration_check_email_pre_signup_activation', '__return_false' );
         


add_action("gform_user_registration_validation", "ignore_already_registered_error", 10, 3);
function ignore_already_registered_error($form, $config, $pagenum){

// Make sure we only run this code on the specified form ID
if($form['id'] != 1) {
    return $form;
}

// Get the ID of the email field from the User Registration config
$email_id = $config['meta']['email'];

// Loop through the current form fields
foreach($form['fields'] as &$field) {

// confirm that we are on the current field ID and that it has failed validation because the email already exists
if($field->id == $email_id && $field->validation_message == 'This email address is already registered')
    $field->failed_validation = false;
}

return $form;

}

Try adding these to your functions.PHP file

You will also need to update the form ID in the second snippet where it says // Make sure we only run this code on the specified form ID. My apologies for the layout. I am on a mobile device right now and the site won’t allow me to properly indent the code.

Also, your default value email field should be added and you should use an email address that is already registered to Wordpress.

Also, this filter requires a 2.4.2 minimum version of the user registration add on.

Thank you for your kind help.

The Snippet did not work at the first attempt. It needs an awkward tweak.

if($field->id == $email_id && $field->validation_message == '**This email address is already registered**')

My site language is not English. It’s Persian.
I changed the “This email address is already registered” part to its equivalent message in Persian. After this surprising customization, it worked.

if($field->id == $email_id && $field->validation_message == '**این ایمیل قبلاً ثبت شده است.**')

But now there is a new problem. When I use this snippet, the form does not update the display name. while before using this snippet it was working.

Glad you got it working. Did you modify the user meta in anyway? Can you take a look at meta and see if any fields were auto updated to connect to a different field?

After adding this snippet, when I use a new email address (not duplicate), the form updates first, last, and display name correctly.

But when I use a duplicate email address, it just updates the first and last name but not the display name.

@chrishajer