Skip to:
Content
Pages
Categories
Search
Top
Bottom

Creating a profile field that only admin can edit


  • groston
    Participant

    @groston

    For our site, we want to designate certain users as being special. That the user is special should appear in their profile, but only the site admin can designate a user as being special.

    In an attempt to implement this behavior, I:

    • added a field to the profile
    • made the field available to all user types
    • hid the field if the email field is not empty, i.e., it is hidden for all users

    I then looked up the field_id in the table wp_bp_xprofile_fields for the newly created field, then added a row to the table wp_bp_xprofile_data using this field_id for each special user.

    And this worked just fine, until…

    One of the special users updated their profile. When this happened, my manually entered row in wp_bp_xprofile_data disappeared. I then conformed that updating the profile causes the entry to disappear – it does.

    Question: Since my approach is not working, what is the proper way to achieve the desired goal?

    Thank you.

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

  • shanebp
    Moderator

    @shanebp

    There are a few ways…
    For example, you could just use usermeta instead of xprofile to store the data.
    And show the field in wp-admin > users > edit
    Then you don’t have to juggle a hidden ( to non-admins ) xprofile field on the edit screen.


    groston
    Participant

    @groston

    shanebp,

    Thanks for the prompt reply.

    The fields that I see in wp-admin > users > edit are all xprofile fields and I do not know how to add usermeta fields. I did see several plugins that provide this functionality, but I am wondering if suchs plugin would play nice with BP.

    It would be easy enough to directly edit the database in the manner your suggested, but that is not the right way to handle this. Would you please provide a little more guidance?


    Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    Please check this link https://stackoverflow.com/questions/6141502/wordpress-create-a-new-usermeta-field-for-users to know how to create user meta fields.

    Thanks


    groston
    Participant

    @groston

    Thx

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar