BuddyDev

Search

[Resolved] Member type pro – profile – if displayed user is member type – echo

  • Participant
    Level: Initiated
    Posts: 3
    Chad on #21859

    Hello,

    I am trying to display on profile page screen , but only if displayed member type is equal to member type.
    Something like this which does not work…

    
       <?php  
        $member_type = bp_get_member_type( bp_displayed_user_id() );
     if ($member_type == 'teacher' ) : {?>
       <div class="teacher-only-class">
         I am a teacher
       </div>
         <?php } endif; ?>
    
         <?php if ($member_type == 'student' ) : {?>
           <div class="student-only-class">
             I am a student
           </div>
             <?php } endif; ?>
    

    edit- i have multiple member types and need to check array for each div class

    Any help would be appreciated
    Thanks

    • This topic was modified 5 years, 9 months ago by Chad.
  • Keymaster
    (BuddyDev Team)
    Posts: 24774
    Brajesh Singh on #21870

    Hi Chad,
    Thank you for the question.

    1. A better option will be to usebp_has_member_type () like this

    
    
    if ( bp_has_member_type( bp_displayed_user_id(), 'teacher' ) ) {
    ?>
    <div class="teacher-only-class">
        I am a teacher
    </div>
    <?php
    }
    

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 3
    Chad on #22014

    That is exactly what I needed.
    Thank you

  • Keymaster
    (BuddyDev Team)
    Posts: 24774
    Brajesh Singh on #22020

    You are welcome 🙂

The topic ‘ [Resolved] Member type pro – profile – if displayed user is member type – echo’ is closed to new replies.

This topic is: resolved