Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to display different profile fields based on user role

  • @shmk

    Participant

    Hello,
    I have a BuddyPress website with various user roles, I’m looking to display the user Profile tab differently (reorder and hide some fields) based on the user role.
    How could I do this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • @henrywright

    Moderator

    user_can() will be a useful function. It accepts a WP_User object or user ID and a role name.

    Ref: https://codex.wordpress.org/Function_Reference/user_can

    @shmk

    Participant

    With user_can() I can check for user capabilities but what BuddyPress template files or hooks I have to use to edit the user profile page? (I’m talking about the ‘website.tld/users/NAME_OF_THE_USER/profile/’ page)

    @henrywright

    Moderator

    All of the core BuddyPress navigation functions are in bp-core/bp-core-buddybar.php. You can see the contents of that file here:

    https://github.com/buddypress/BuddyPress/blob/master/src/bp-core/bp-core-buddybar.php

    @youmin

    Participant

    I think he is referring to roles based on member_type, not by wp capability (role).
    As he mentioned above, his buddypress website having various roles, so he wants to display different profile field based on created role.

    If role is a (member_type) lyricist = profile field
    If role is a (member_type) singer = profile field

    @shmk

    Participant

    Yes, it’s like @youmin is saying.

    If role equal A show in profile B and C
    If role equal X show in profile Y and Z.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to display different profile fields based on user role’ is closed to new replies.
Skip to toolbar