Skip to:
Content
Pages
Categories
Search
Top
Bottom

Relational Fields between two types of members


  • commexpert
    Participant

    @commexpert

    HI

    I have two groups of users STUDENTS and TEACHERS
    I want to link each student to a teachers, meaning the name of a teacher should be linked to each student profile.
    In the registration form, the student should be able to select a teacher in a dropbox that would listing all the names of the registered teachers.
    The name of the selected teacher will be stored in this field.

    How can I achieve this ?

    Thanks

Viewing 1 replies (of 1 total)
  • Your task is a compilation of several steps.

    1) You need to add a custom field to BuddyPress registration form
    See this https://buddypress.org/support/topic/how-to-display-a-custom-field/ or similar (just google).

    2) You need to get the list of users by a member type to display in a <select> field created in 1).
    See https://codex.buddypress.org/developer/member-types/ and its “Querying by member type” section.

    3) In 1) you created and it’s also written how to store that data, I suggest using usermeta (update_user_meta()). You should store not the teachers names, but their ids in metas.

    4) Now you need to display this info in user profile.
    Investigate wp-content/plugins/buddypress/src/bp-templates/bp-legacy/buddypress/members/single/profile/profile-loop.php file, you will see there several hooks that may be useful for you. There you will just echo what you need.
    Example: get_user_by('id', get_user_meta(bp_displayed_user_id(), 'teacher_id'))->display_name; or similar using BuddyPress functions.

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