Skip to:
Content
Pages
Categories
Search
Top
Bottom

Extending User Profiles with dynamic options / post relationships


  • Ross Wintle
    Participant

    @magicroundabout

    Hi there,

    What is the best way to programmatically extend a user profile? Basically I have a custom post type called “Skills” in WordPress and I want my BuddyPress members to be able say that they have a set of skills and create a relationships between the member and the Skill using profile field data (or possibly standard usermeta, I’m not sure which is best).

    Are there some documented hooks for adding sections to user profile screens?

    Thanks

    Ross

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

  • shanebp
    Moderator

    @shanebp

    You could write a new component.
    But I usually just create a plugin.
    Use bp_core_new_nav_item() and bp_core_new_subnav_item() to add tabs to a profile.

    Then use the ‘screen_function’ field to call functions that handle CRUD, etc for your cpt.
    Re xprofile vs. usermeta, that’s your call. Either would work.


    Ross Wintle
    Participant

    @magicroundabout

    Thanks Shane.

    I was thinking more of something that’s like profile fields, that you edit in the member sign-up and profile edit screens, rather than creating new screens. What I’d REALLY like is something like the Group extension API for users. But instead the registration/register.php and /members/single/profile/edit.php templates seem to have a large amount of almost-duplicated code and inconsistent hooks.

    Yeah, I know – if I want an extension system I should contribute it, right? 🙂

    Any thoughts on adding profile fields with dynamic values in the way that I need? The best way would seem to be to use something like the bp_custom_profile_edit_fields and bp_signup_profile_fields action hooks, but I’m not sure that they are specific enough.

    Thanks

    Ross


    shanebp
    Moderator

    @shanebp

    I’m still not clear on what you’re trying to do.

    Those hooks should provide a starting point.
    But adding profile fields dynamically and adding/setting dynamic values to existing fields are 2 different things.

    See:
    buddypress\bp-xprofile\bp-xprofile-admin.php
    re adding adding profile fields dynamically.

    The latter item should be quite straightforward.

    Then, as you point out, there is the lamentable difference between field handling in reg and profile.


    Ross Wintle
    Participant

    @magicroundabout

    Thanks again Shane. I’ll try to explain again.

    At high level, I want users, in their user profile, to be able to select one or more skills that they have. Skills are posts of a post type.

    At lower level, I want, in a BP user profile, a field which is either a multi-select, or a set of checkboxes. The values selectable should be titles of posts from the “Skills” post type (I’ll actually save the IDs of the posts, but the titles should be displayed).

    The user should be able to select these values both when registering and when editing their profile.

    Possible implementations I can think of would be:
    – Implement a new field TYPE called “skill”, create a field of that type in BuddyPress, and write some hooks that display and save the field.
    – Add some custom code using action hooks to the bottom of the registration and edit profile screens.

    I know it’s kinda hard to explain in a short forum post. There just doesn’t seem to be some simple, documented hooks that a plugin can use to extend the user profiles with new custom fields of new types and I was looking for some guidance/best practice for doing this.

    Thanks again for your help.

    Ross


    danbp
    Moderator

    @danbp

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Extending User Profiles with dynamic options / post relationships’ is closed to new replies.
Skip to toolbar