• Resolved Erfan MHDi

    (@erfanmhd)


    hello,
    i’m using ultimate member and Digits to register user on my sites using phone number as primary and email as secondary way of user recognition.

    so i need to make email address on optional field instead of required.
    but when i uncheck “Is this field required?” in registration form edit page on back end, i still get error on registration page on front end that email address field must be filled.
    (it’s because wordpress needs an email address for user recognition i guess)
    and when i remove email field from registration form i can register a new user without email but in admin panel i can see an email like “[email protected]” is assigned to user.

    i was wondering if i can make registration email field optional, not required. if possible and if not maybe at least i can change that email to “[email protected]” without www.

    also i need to give user the ability to add a password to their account after they signup with phone number and otp!
    when i remove the password field from registration form and users register on site with only their phone number they cannot even use change password field inside um account page. cause there is no “current password” they can use there.
    can remove “current password field” from change password form inside um account page (only for user who has no password of course )?

    i’ll appreciate if you guys can help me with this.
    and thanks for your great job on UM plugin by the way! ??

    • This topic was modified 3 years, 9 months ago by Erfan MHDi.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @erfanmhd

    To change the generated Email address, you can use this filter hook:

    add_filter("um_user_register_submitted__email", function( $email ){
         // do something
       return $email;
    });

    To remove the Current Password field from the passwords tab, you can try this code snippet below:

    add_filter("um_account_password_require_current","__return_false");

    Regards,

    • This reply was modified 3 years, 9 months ago by Champ Camba.
    Thread Starter Erfan MHDi

    (@erfanmhd)

    Thanks @champsupertramp,
    just what i wanted!
    also can i add an if condition for them too ?
    for example for email address can i make email address field optional ?
    and make an if condition like this :

    if ( user filled email address on registration ) {
       $email = user email 
    } else {
       add_filter("um_user_register_submitted__email", function( $email ){
          $email = [email protected]
          return $email;
       });
    }

    and for current password field something to detect that current user has any password or not, if not then user is “Adding Password” so remove current password field, if yes then user is “Changing Password” so show current password field.

    Thanks mate ??

    Thread Starter Erfan MHDi

    (@erfanmhd)

    also appreciate it if you can tell me how to get fields value like username or phone number inside this filter hook :

    add_filter("um_user_register_submitted__email", function( $email ){
         // do something
       return $email;
    });

    i’ve tried
    $email = $user_login . ‘@domain.com’;
    $email = $username . ‘@domain.com’;
    $email = um_fetch_user( $user_id ) . ‘@domain.com’;

    but no luck so far …

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @erfanmhd

    You can try dumping the $_REQUEST to get the raw data post.

    add_filter("um_user_register_submitted__email", function( $email ){
         var_dump( $_REQUEST );
         wp_die("test");
       return $email;
    });

    Regards,

    Thread Starter Erfan MHDi

    (@erfanmhd)

    Hello @champsupertramp,
    Thanks, with your help i replaced [email protected] with [email protected] now.

    just 2 more thing :
    1. how can i detect if user has a password or not ? so i can remove the current password field ONLY if there is no password set for user yet.

    2. how to make email address field optional in registration form? it’s a required field even when i uncheck the “Is this field required?” option in Backend.

    Thanks for your time and help
    i really appreciate it ??

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @erfanmhd

    1. Unfortunately, WP generates a hash password with wp_hash_password() function, even if the password field is empty. It stores the hash pass in wp_users table > user_pass column.

    2. You can try the following snippet to make the user_email field optional:

    add_action("um_main_register_fields", function(){
    
        $user_email_error = UM()->form()->errors['user_email'];
        if( 'You must provide your email' == $user_email_error ){
            unset( UM()->form()->errors[ 'user_email' ] );
            
        }
    }, 99);

    Regards,

    Thread Starter Erfan MHDi

    (@erfanmhd)

    Thanks Man,
    i Appreciate your help. ??

    • This reply was modified 3 years, 9 months ago by Erfan MHDi.
Viewing 7 replies - 1 through 7 (of 7 total)