BuddyDev

Search

Replies

  • Participant
    Level: Initiated
    Posts: 5
    ashwin shetty on #41924

    Hey Brajesh and Ravi,

    Thank you for your help. I contacted the author and got the file to get proper hooks and the code Ravi shared worked like a charm. Thanks again.

    I would request an additional code so that the member types can also be seen on the user profile page under the profile name just as the code you shared allows me to see member type under the name on the members page.

    Thanks in advance.

  • Participant
    Level: Initiated
    Posts: 5
    ashwin shetty on #41840

    Ravi, The code is not present in the members-loop.php

  • Participant
    Level: Initiated
    Posts: 5
    ashwin shetty on #41836

    Hey Ravi, thank you for the message. I placed the code in the functions.php (child theme) but it did not reflect the member type under the user name neither on members directory or user profile page. Is there something I am doing wrong?

    Site URL is : https://youtooart.com

  • Participant
    Level: Initiated
    Posts: 5
    ashwin shetty on #41827

    Here it is. Can you help me with the correct code. My site link is youtooart.com Your help is much appretiated.

    ` /**
    * Get an array of member type labels based on member types.
    *
    * @param array $member_types member types.
    *
    * @return array
    */
    function buddydev_get_member_type_labels( $member_types ) {

    $labels = array();
    if ( ! $member_types ) {
    return $labels;
    }
    foreach ( $member_types as $member_type ) {
    $mtype_object = bp_get_member_type_object( $member_type );
    if ( ! $mtype_object ) {
    continue;
    }

    $labels[] = $mtype_object->labels[‘singular_name’];
    }

    return $labels;
    }

    /**
    * Print the list of member types of the user in member directory.
    */
    function buddydev_show_member_type_labels() {
    $user_id = bp_get_member_user_id();

    if ( ! $user_id ) {
    return;// It should never happen but in case someone put the ac
    }

    $labels = buddydev_get_member_type_labels( bp_get_member_type( $user_id, false ) );

    echo join( ‘, ‘, $labels );
    }

    add_action( ‘bp_directory_members_item’, ‘buddydev_show_member_type_labels’ );

    function buddydev_show_member_type_for_displayed_user() {
    if ( ! bp_is_user() ) {
    return; // just a safeguard, it should never happen.
    }

    $user_id = bp_displayed_user_id();
    $labels = buddydev_get_member_type_labels( bp_get_member_type( $user_id, false ) );

    echo join( ‘, ‘, $labels );
    }

    add_action( ‘bp_member_header_actions’, ‘buddydev_show_member_type_for_displayed_user’ ); `

  • Participant
    Level: Initiated
    Posts: 5
    ashwin shetty on #41320

    Hi Brajesh, I actually want to use the auto link. It works perfectly when there is more than one member type selected. If only it can be done with single-member type too