0

I am using the plugin Paid Membership Pro (free version). Just below the header, if a user is logged into my site I would like it to say:

Welcome Username

How could I do this?

This is how to get the membership level:

if(
    is_user_logged_in()
    && function_exists('pmpro_hasMembershipLevel')
    && pmpro_hasMembershipLevel()
) {
    global $current_user;
    $current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
    echo 'Membership Level: ' . $current_user->membership_level->name;
}

How do I use that to display username instead of membership level?

Many Thanks,

Paul

  • 1
    Look at this – nmr Jun 3 at 15:52
0

Following @nmr's comment, you can try this:

if( is_user_logged_in() ) {
    global $current_user;
    echo 'Hello, ' . esc_html( $current_user->display_name );
}
  • pmpro_hasMembershipLevel() is not needed to display the username. – nmr Jun 3 at 16:00
  • Thanks @nmr - I just glazed over that bit, d'oh! – phatskat Jun 3 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.