Add new ID field in wp-login (2 posts)

  1. aneesiqbalbhatti
    Posted 3 years ago #

    Hi, I am completely a newbie and I've got a work that I cant get through. A friend of me had asked me to put an extra input field of "ID" in the login form, so, that every user will have to provide their ID also in order to login to the website. I thought it would be easy but now when I've looked into the wp-login.php file, I think I surely need some expert advice for that. (as i cant understand it)
    Please tell me if there's such plugin or something. Or if some expert can just help me out by giving a code. Any kind of help will be highly appreciated. Thanx in advance.
    Anees Iqbal

  2. bcworkz
    Posted 3 years ago #

    The solution is fairly simple if you know how to hook actions and filters. Discovering this on my own was not so easy, you have to know where to look. I did not, and essentially stumbled on this solution by accident.

    To have another field show up on the login form, hook the action 'login_form' and simply echo out the HTML, and it will display after the default fields.

    To process the the submitted content of the field, hook the filter 'authenticate' and get the content from $_POST['your_field_name'] and do whatever needs doing with it.

    More on hooking actions and filters are in Plugin API. The techniques described work equally well from a child theme functions.php as they do from a plugin, so you can follow either path.

Topic Closed

This topic has been closed to new replies.

About this Topic