• Resolved illuder

    (@illuder)


    Hi
    In the new user registration page (register.php), i need the following to happen:
    1- The header USERNAME must be changed to Mobile Number
    2- The field must accept digits only

    Is there a function in the plugin which can do this?
    Tx
    Mo

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support sanjuacharya77

    (@sanjuacharya77)

    Hi @illuder,

    To set username as a digit only, you will need to paste the following code in your active theme’s functions.php file.

    Here is the code:

    add_action( 'user_registration_validate_user_login','ur_validate_username_field',10,4);
    function ur_validate_username_field($single_form_field, $data, $filter_hook, $form_id) {	
    	$field_label = isset( $data->label ) ? $data->label : '';
    	$value = isset( $data->value ) ? $data->value : '';
    	if( 1 !== preg_match('~[0-9]~', $value ) ) {
    	    add_filter( $filter_hook, function ( $msg ) use ( $field_label ) {
    	        return __( $field_label . 'should contain a  number.', 'user-registration' );
    	   });
    	}
    } 

    Do let me know whether it helps or not and I will get back to you.

    Thanks and Regards!

    Thread Starter illuder

    (@illuder)

    apologies for the delayed response here. I only just noticed this reply.
    I am still working on the project.

    Whilst adding this mentioned code in my Kleo Theme for Buddypress function.php file, it gave me a serious error.
    “There has been a critical error on your website.
    Learn more about debugging in WordPress.”

    https://my.lakewest.co.za/register

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Username as Digits only’ is closed to new replies.