Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Amrit Kumar Shrestha

    (@shresthauzwal)

    Hi @paulabender,

    Sorry but I am a bit unclear about your query. If you could let me know in a bit more detail then it would be easy for me to assist you.
    Let me know your requirements in a bit more detail and I will get back to you.

    Regards!

    Thread Starter paulabender

    (@paulabender)

    Hello @shresthauzwal

    Thanks for your quick response. I need the username field of the registration form to only accepts numbers.

    Plugin Support Amrit Kumar Shrestha

    (@shresthauzwal)

    Hi Paula,

    Thank you for writing in,

    Could you please install the https://ww.wp.xz.cn/plugins/code-snippets/ plugin on your site and add the following code to it and activate the code snippets. This plugin will help you to secure the custom modification on the plugin.

    add_action( 'user_registration_validate_user_login', 'ur_validate_user_login_field', 10, 4 );
    function ur_validate_user_login_field( $single_form_field, $data, $filter_hook, $form_id ) {
        $field_label = isset( $data->label ) ? $data->label : '';
        $username       = isset( $data->value ) ? $data->value : '';
        error_log(print_r($username, true));
        if (!is_numeric( $username ) ){
            add_filter(
            $filter_hook,
            function ( $msg ) use ( $field_label ) {
            return __( $field_label . ' cannot contain string.', 'user-registration' );
            }
            );
        }
    }

    Regards!

    Thread Starter paulabender

    (@paulabender)

    Hi Amrit,

    Thank you for shearing the code. I get this error: syntax error, unexpected ‘&’

    Regards

    Plugin Support Amrit Kumar Shrestha

    (@shresthauzwal)

    Hi @paulabender,

    Thank you for writing back,

    We have tested the code on our testing server but we did not find such issues, it is working fine. Could you please provide us a screenshot of the error?

    Regards!

    Thread Starter paulabender

    (@paulabender)

    Hi Amrit

    Someone from the support team emailed me another code. That’s the one I tried. I thought it was the same as the one you shared with me.

    I tried now with your code and it worked perfectly.

    So thanks a lot for the code and for asking (so I tried again);)`

    Plugin Support Amrit Kumar Shrestha

    (@shresthauzwal)

    Hi @paulabender,

    Thank you for writing back,

    Glad to know that the issue is resolved. ​If you have a moment to spare then we would really appreciate your review of our plugin. Please click on this link https://ww.wp.xz.cn/support/plugin/user-registration/reviews/#new-post it would boast us to make the free version better and encourage us in providing continued free support like

    Regards!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘User_login validation numbers only’ is closed to new replies.