Use global $authordata
:
Testing for roles:
global $authordata;
if ( in_array( 'administrator', $authordata->roles ) )
{
echo 'Hello Admin!';
}
elseif ( in_array( 'editor', $authordata->roles ) )
{
// echo something else
}
Or testing for capabilities:
if ( ! empty ( $authordata->allcaps['manage_options'] ) )
{
echo 'The author can manage options';
}
elseif ( ! empty ( $authordata->allcaps['edit_others_posts'] ) )
{
// echo something else
}
Related Posts:
- Echo author slug in post edit page
- How to change the case of all post titles to “Title Case”
- Hook that get’s triggered when the author of a post is changed
- Dynamically add id to heading tags
- the_author() returns empty string
- Prevent Authors from viewing each others Posts
- Confirmation box when submitting post for review
- Display Random Author with Details in Sidebar
- Ajax Load More Posts in Category Page
- How to show list of posts by author and category?
- WordPress: How to get the current logged in author page URL?
- How to add editor’s name to entry meta byline?
- Different permalink for posts and authors
- Publish pending article from front end with a button?
- List latest posts in WP-Admin
- Update all posts automatically when using post_meta
- How to display posts by current user/author in a custom page template?
- Restrict users from editing post based on the age of the post
- Query posts distinct authors
- Change slug with custom field
- Restrict access to post if it is currently being edited
- Restrict the Number of Posts an Author can Publish (over time)?
- Search posts by post author name
- Get the user type of an author
- Getting an alphabetic post list with two letters onclick on letter
- Show the title of the latest post by author
- Create new category upon save based on post information
- Find most recent authors
- Show author post count in sidebar – Variable
- which action to hook to in order to perform post-publish action
- Get current users post URL?
- Get the author of the latest revision
- Filter posts by author and category simultaneously
- Custom Post Type & Author not associating, user post count is 0, api doesn’t return author in post objects
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- Strange switch_to_blog() issue
- Post author is changed to admin after his post is modified by admin
- POST from jQuery to PHP
- Search widget breaks when using multiple loops?
- Get all posts by post_author
- How can I control multiple editing of wordpress posts?
- Multiple authors for single post without plugin
- Limit number of posts a user can make per minute?
- $post object is null
- Authors in menu, template list post by author
- Show the author’s count of total amount of posts assign to a custom taxonomy term
- Author must complete profile info before they can publish a post?
- Advanced Custom Fields – Storing array value for further usage
- Function to show random posts from a category
- WP rest api returns 404 only when author param is used
- How can I list random authors from current post category?
- how to show comments only author which send own posts in wordpress
- Restricting displayed posts to posts from only select authors
- Author post count in category
- Posts missing on author page
- Change of author not updating
- Limit Post Creation Count by Author or Role
- Display post by Random Authors on Page Refresh
- What permissions does a role need for the user to be assigned as the author of a post?
- On WordPress Search, how to search post from Author meta also
- How to hide meta from search result only on pages?
- Numbering author posts in posts query
- Custom author search
- Changing the Category for all posts of an Author
- List of authors posts minus very latest
- Displaying friend’s posts only
- show latest authors blog post
- Getting posts from multiple users?
- Display the current post author and his url in the post header
- How to limit the number of results for all query_posts on mysite
- Create a Page Template Which Displays All Posts by Current User
- Show a Category Specific Info Box
- Set the limit to allow author when make post!
- How to get all the terms of a post
- Get first comment link on the post itself
- User driven content problems
- How can i retrive the movies, trailers, news in a single page using search
- How can I create a menu items from meta box based on users input
- Older entries link within a category page
- How do I display a full post, not just an excerpt?
- Show last post of employee in his profile page
- Remove read more
- Insert new post for each user infinite loop error
- How to get single post by one author?
- List direct children of page
- Unable to get posts with category on my page
- wordpress radio button on single post page
- How *not* to show the last post on the latest posts list
- Create post from form with image
- Notify Author of the post if admin deletes his post and perform some function
- Exclude a ‘portfolio’ custom category?
- Display a custom field rating system in the front end
- how to show all type of author posts in author page (SOLVED)
- get value from post to sidebar
- How to show total view count across all posts for an author
- Adding a content rating system
- How can I add Author’s phone number to wp profile and make it appear in wp-admin/edit.php columns
- Add author section on Author archive posts
- How to make the Post Author name fixed as “Editorial Staff” even if there are multiple authors?
- users followin the blog post author