• I’m wanting to enhance the standard “User > Your Profile” page.

    I need to allow a user to create and associate simple (but potentially multiple records) with their account.

    Example as follows;

    The site will cater for pet owners who may have a single, multiple (or possibly at present no) pets.

    So I’d like a “Add pet” button, a list of current pets with an associated “Edit or delete” option.

    I have limited WordPress experience.

    I’m not asking for all the code! But I’d like a pointer in the right direction. I’m not sure whether out of the box the core functionality will cater for this many to one relationship or whether I’ll need to start making new MySQL tables etc.

    If someone can point me in the right direction I’d be very grateful.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    Take a look at wp-admin/user-edit.php. Look for the the various calls for do_action(). You can hook into any of these actions and output your own custom code, as long as it is inside the <form> block. In particular, look at the ‘profile_personal_options’ action.

    You also need to hook the ‘profile_update’ action so that you can save your input field data (in $_POST) when the form is submitted.

    Thread Starter thomasario

    (@thomasario)

    Hi bcworkz

    Great – that’s very useful. I appreciate your help 🙂

    I think I was also trying to pin down whether there is anything “built in” to WordPress to allow this many to one relationship i.e. my plan was to add a new database table and then add pets identified by the user id of the logged in user which could then be subsequently filtered.

    That’s fine – but in my ignorance of WordPress I could be reinventing the wheel when the heavy lifting to perform this type of task could already exist. Hope that makes sense?

    Moderator bcworkz

    (@bcworkz)

    Sorry for the slow response, I’ve been traveling.

    The facility you could use that is built into WP is the usermeta table. You can use functions like update_user_meta() and get_user_meta() to manage data, and use the ‘meta_query’ arguments in instantiating a WP_User_Query class object to query for users by values you store this way.

    If you query needs exceed these basic capabilities, creating a custom table related by user ID is a perfectly acceptable approach, though you are obviously on your own when it comes to interfacing with it.

    I’m also interested in implementing something very similar, users creating an unknown number of items while signing up and being able to edit/delete/update them. Have you considered using plugins for extending user profiles?
    I’m guessing there might be a way to do this using custom post types. Any pointers in that direction?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘User profile enhancement – can the WordPress core support this easily?’ is closed to new replies.