Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Force/show nickname field during user registration

Discussion in 'Misc WordPress Requests' started by bcworkz, Oct 20, 2017.

  1. bcworkz

    Guest

    Reply To: Force/show nickname field during user registration, by bcworkz

    Oh, that “registration” form! New user admin screen is a better label for that

    Use the ‘user_new_form’ action to output your form field. It’ll appear after all the default fields and before the Add New User button. It’ll be outside the default field table, so replicating the same structure might be needed to achieve the same styling. (or apply your own)

    To save the entered value, use the ‘register_user’ action to get the value from $_POST, validate and sanitize, then save in the DB in usermeta under the key “nickname”. Validation should include searching the DB for another matching nickname. Unfortunately, it’s too late here to reject the new user if a match is found, all you can do is not save the value and maybe cause a message to display on the next screen. Or go ahead and allow duplicate nicknames, there’s no real conflict, just potential confusion.

    Probably a better way to check for existing nicknames is to use Ajax to do a check when the field blur JS event fires, before the form is even submitted.

    Reply To: Force/show nickname field during user registration
     
    #1

Share This Page

Web Hosting