Skip to:
Content
Pages
Categories
Search
Top
Bottom

If displayed_user_can then ….

  • @jimhellas

    Member

    I want to show a special icon next to admins and premium members names in their profile (preferably in the activity stream as well). Is there a function that checks if something is true about the displayed user, as the current_user_can function does?

    e.g, I want something that does something similar to this, but it takes into account the displayed user:
    <?php if(current_user_can(‘level_1’)) : ?>PREMIUM MEMBER<?php endif; ?>

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • @pcwriter

    Participant

    Check out the codex here for a full list of all functions (great stuff!):
    https://codex.wordpress.org/Function_Reference

    @anonymized-96400

    Inactive

    well, you could check against usermeta for example:

    `global $bp;
    $meta = get_usermeta( $bp->displayed_user->id, ‘member_status’ );
    if( $meta == ‘premium’ )
    {
    //do stuff, like showing a badge
    }
    else
    {
    //show something else or do nothing
    }`

    doing something like this in a loop will add a lot of database calls though. also in a loop you won’t be able to use $bp->displayed_user->id.

    you could also check against profile field data.

    @jimhellas

    Member

    Thanks for the ideas.

    I’ll try to check against some usermeta (not for the loop though…). I guess it will work for the profile pages :)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘If displayed_user_can then ….’ is closed to new replies.
Skip to toolbar