• Dear
    we add the next code to let us can be able to use mobile field instead username in some registration form and it is work and at the same time I need another registration form that is normal (use username)
    but when use the normal form
    the username of the created user become empty in user edit profile page in backend

    I need to use tow registration form

    form uses mobile field as username after using the next code it works right and the created username is phone number (right)

    add_action("um_submit_form_register","um_090321_mobile_number_zero_validation", 1 );
    function um_090321_mobile_number_zero_validation( $post_form ){
     
        if(  isset( $post_form['mobile_number'] ) && ! empty( $post_form['mobile_number'] ) ){
            if ( strpos( $post_form['mobile_number'], '0') !== 0) {
                UM()->form()->add_error('mobile_number', __( 'Mobile Number must begin with 0', 'ultimate-member' ) );
            }
            if( username_exists( $post_form['mobile_number'] ) )  {
                UM()->form()->add_error('mobile_number', __( 'Mobile Number already registered', 'ultimate-member' ) );
            }        
        }
    }
    
    add_action("um_user_register","um_090321_after_register_complete", -1, 2 );
    function um_090321_after_register_complete( $user_id, $args ){
       
        global $wpdb;
    
        $wpdb->update( $wpdb->users, array('user_login' => $args['mobile_number'] ), array('ID' => $user_id));
    
    }

    but
    when using normal form that use username field to create username I got the next issue
    the username field of the created user is empty without any username inside it

    so please how to fix this issue
    regards

Viewing 13 replies - 16 through 28 (of 28 total)
  • @makmerghen

    When testing the geolocation/mobile country code and country flag plugin I found that you need to make a CSS change.

    Add to WP Appearance -> Customize -> Additional CSS:

    .um .um-form input[type=tel] {
        padding: 0 40px !important;
        width: 100%;
        display: block !important;
        -moz-border-radius: 2px;
        -webkit-border-radius: 2px;
        border-radius: 2px;
        outline: none !important;
        cursor: text !important;
        font-size: 15px !important;
        height: 40px !important;
        box-sizing: border-box !important;
        box-shadow: none !important;
        margin: 0 !important;
        position: static;
        outline: none !important;
    }

    Where you can change the padding of 40px for best result.

    Thread Starter makmerghen

    (@makmerghen)

    @missveronicatv I installed International Telephone Input With Flags And Dial Codes
    and I activated it from its setting and I added the css code you gave
    but mobile field still without country code so please advise

    @makmerghen

    The code snippet above was only for Registration Page.

    This code snippet will also change the “text” field to “tel” while editing the Profile Page so you can make a replacement with this:

    add_filter( "um_mobile_number_form_edit_field", "um_mobile_number_form_edit_field_tel", 10, 2 );
    add_filter( "um_phone_number_form_edit_field", "um_mobile_number_form_edit_field_tel", 10, 2 );
        
        function um_mobile_number_form_edit_field_tel( $output, $set_mode ) {
            
            if( $set_mode == 'register' || $set_mode == 'profile' ) {
                $output = str_replace( 'type="text"', 'type="tel"', $output );
            }
            return $output;
        }

    Profile Page editing you must clear an old mobile number to get the country code displayed.

    This code snippet will make the Mobile/Phone numbers clickable on mobiles ie so you can direct call the user number.

    add_filter( 'um_view_field_value_text', 'my_custom_view_field_value', 10, 2 );
    
    function my_custom_view_field_value( $res, $data ) {
    	
    	if( $data['metakey'] == 'phone_number' || $data['metakey'] == 'mobile_number' ) {
            if( !empty( $res )) {
                $res = '<a href="tel:' . str_replace( array( '(', ')', '.', '-', ' ' ), '', $res ) . '">' . $res . '</a>';
            }
    	}
    	return $res;
    }
    Thread Starter makmerghen

    (@makmerghen)

    @missveronicatv prefect my lady God bless you

    Thread Starter makmerghen

    (@makmerghen)

    @missveronicatv generally want to know if I have any issue and need consultant can I contact you ?

    Thread Starter makmerghen

    (@makmerghen)

    Dear @missveronicatv I have an issue in mobile field after using geolocation/mobile country code and country flag plugin
    I m using tow languages English RTL and Arabic LTR
    when using English every thing is okay number appear flag +20
    but when LTR it like this flag 20+
    so please how to make only this field to avoid changing to LTR

    regards

    @makmerghen

    You can try to replace existing CSS padding: 0 40px !important;
    with padding-inline: 40px 10px !important;

    where the 40px is the start field padding ie distance away from the flag
    and the 10px is padding at the end of the field for your Arabic LTR mobile number.

    You can adjust both values if needed.

    • This reply was modified 2 years, 7 months ago by missveronica.
    Thread Starter makmerghen

    (@makmerghen)

    @missveronicatv I did what you said but css editor mark padding-inline with red color as if it is mistake and even after saving the new edit no thing changed only it is adjusted with English language and not adjusted as I described before when change language to Arabic rtl

    so please advise
    regards

    @makmerghen

    Sorry my mistake the 20+/+20 are your country codes.

    1. Switch back to the first version of the CSS: padding: 0 40px !important;

    2. Replace the code snippet add-on-1.php with current updated code at:

    https://github.com/MissVeronica/UM-Mobile-Number-Login

    The update will switch to LTR for the Mobile/Phone number fields
    and you will get flag +20 also for profile forms in Arabic.

    @makmerghen

    A second update of the code snippet add-on-1.php to also switch to LTR when displaying the profile.

    Thread Starter makmerghen

    (@makmerghen)

    @missveronicatv thank you a lot for the update it adjusted the field

    one more thing please
    as I told I used this code
    add_filter( 'um_registration_for_loggedin_users', '__return_true' );
    to let logged in user can register a new users while he is logged in
    after filling all registration form fields included mobile number field and press register and finished the registration the page is refreshed and all field became empty except the mobile number field it still contain the last number I used to register the last user
    so please how to clear also the mobile number field after the registration?

    wish you all the best

    • This reply was modified 2 years, 7 months ago by makmerghen.

    @makmerghen

    A third update of the code snippet add-on-1.php, now removing any mobile/phone numbers preset in the Registration Form.

    Download and replace the code snippet.

    Thread Starter makmerghen

    (@makmerghen)

    @missveronicatv thank you very much and all the best for you

Viewing 13 replies - 16 through 28 (of 28 total)
  • The topic ‘issue when using mobile field as username’ is closed to new replies.