• I know that user_level has been depreciated.

    So how now can one determine if a user . not the current user has certain capabilities?

    (from my second post – the more general question I’m trying to answer is this…)
    How can you determine if a unique userID has certain capabilities?
    EX: highlight comments from all users with that capability
    EX2: change author bio based on users with that capability.

    So for example:
    Below each post is an author box.
    I want to show a lot more information for my administrator / editors than for authors

    global $authordata;
    $authorid = $authordata -> ID;
    
    if ($authorid <strong>can moderate_comments</strong>){
     //show email
    }elseif ($authorid <strong>can edit_published_posts</strong>){
     //show smiley face ?
    }
    // display for all is here.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Acts7

    (@acts7)

    I found this.

    if (author_can( $post, 'add_users' )) {
                        // do something if the author of the post $post has $capability
                        echo'WORKING';
                    }else{
                        echo'can\'t add users';
                    }

    Is there a better route to do this?
    Because I would also like to use the function to highlight comments from that same user.

    Isn’t there a simple?
    “” can userID add_users “”

    I guess a better question would be this:
    How could you use the same function to highlight all admin/editor comments?
    I’ve found “Author Comments Highlighted” but that is for only the author.
    How would you highlight comments from all users with a certain capability?

    Thread Starter Acts7

    (@acts7)

    WOOO HOOOO
    THANK YOU JESUS /././ for Gary Cao

    Ultimate Guide To Roles and Capabilities

    Graph of all Roles : Capabilities

    So here’s what I did:

    function author_bio_display()
    {
    global $authordata;
    global $post;
    $user = new WP_User( $authordata->ID );
    //if ( $user->has_cap( $cap_name ) ) {
    if ( $user->has_cap( moderate_comments ) ) {
    // do something
    echo’THANK YOU JESUS THIS WORKED’;
    }
    // rest of my code here is unnecessary
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘UserID Role shapes front end content (not current user)’ is closed to new replies.