Grab wp profile info and fill in form field

3 replies
How would I go about grabbing the name and address of a logged in (Wordpress) user and autofilling form fields with that info?
#field #fill #form #grab #info #profile
  • Profile picture of the author jamesc1985
    First of all:

    1) Are you looking for a plugin that is already made to do that or are you looking to build one?

    2) do you have any examples of software that do it.


    Chrome and other browsers do have a auto form fill but the user has to select it. There are other ways of doing it by face book but would still require the users permission.

    Thanks

    James
    {{ DiscussionBoard.errors[8319930].message }}
    • Profile picture of the author rhinocl
      Neither, I just want to grab those values and enter them into some form fields as the default values.
      Of course if there is a plugin that does it, that's good. The rest of the form will basically be a small shopping cart.
      {{ DiscussionBoard.errors[8320465].message }}
      • Profile picture of the author MikeOranguu
        Howdy,

        To access the current profile details of a logged in user you need to use the following function:

        Function Reference/get currentuserinfo « WordPress Codex

        This function will reutrn a php object of major details regarding the logged in user such as, ID, name, email etc. You will see a full list of everything that's returned in the above link.

        You will most likely need to use this in combination with the get_user_meta functions, of which details can be found here:

        Function Reference/get user meta « WordPress Codex

        Theme and plugin developers such as myself tend to store those additional details such as address and so on in the user meta table, so it's a good bet as to where things are. To use the above function just pass it the user ID you obtained with the first function and along with the meta data name and the function will return it's value from the database.

        Once you have the information you need such as name and address from using the above functions, it's simple a case of echoing out those details into the correct value attributes of the form fields you want prefilled.

        That's just a brief high level overview of how to do the task at hand, but if you have any more questions i'm more than happy to answer them.
        {{ DiscussionBoard.errors[8322220].message }}

Trending Topics