This topic has 5 replies, 2 voices, and was last updated 9 years by kcdrip.

  • Author
  • #51263
     kcdrip
    Participant

    Hello, I am building a membership site with free and paid memberships. I would like to be able to display the membership type on every profile underneath the avatar like it does on the users own profile page. Any suggestions?

    #51391
     Radu
    Moderator

    Hello

    You can use this function

    COPY CODE
    
    function kleo_membership_info()
    {
    
      global $membership_levels,$current_user;
      if (! $membership_levels) {
        return;
      }
      
    global $bp;
    
    $puid = $bp->displayed_user->id;
    
    //print_r (pmpro_getMembershipLevelForUser($puid));
    
      if ($puid) {
    
        if ( pmpro_getMembershipLevelForUser($puid) ) {
            $membership = pmpro_getMembershipLevelForUser($puid);
    
          echo '<a href="'.pmpro_url("account").'"><span class="label radius pmpro_label">'.$membership->name.'</span></a>';
        }
        else
        {
          echo '<a href="'.pmpro_url("levels").'"><span class="label radius pmpro_label">'.__("Upgrade account",'kleo_framework').'</span></a>';
        }
      }
    }
    
    add_action('bp_before_member_header_meta', 'kleo_membership_info');
    
    

    The membership level will be seen by anyone

    You can customize and extend functionality of this function.

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #51407
     kcdrip
    Participant

    Thank you so much Radu!

    #51409
     kcdrip
    Participant

    Question do I add this to the functions.php in my child theme? I added and got a syntax error “Parse error: syntax error, unexpected end of file in /home3/kcdrip/public_html/wp-content/themes/kleo-child/functions.php on line 11”

    #51469
     Radu
    Moderator

    Please provide entire content of functions.php from kleo-child in a txt file.

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #51723
     kcdrip
    Participant

    Sorry, I found the issue “//print_r (pmpro_getMembershipLevelForUser($puid));” was messing up the php file so I just closed the line. Thank you!

Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?