Basically you are asking a function to check the post author role. You can use user_can()
function.
if(user_can('administrator'))
{
//Write your code if the admin
}
current_user_can()
: https://codex.wordpress.org/Function_Reference/current_user_can
user_can()
: https://codex.wordpress.org/Function_Reference/user_can
Related Posts:
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Why does WordPress add 0 (zero) to an Ajax response?
- Passing arguments to a admin menu page callback?
- function deactivate_plugins does not exist
- what’s the meaning of the field wp_capabilities in table wp_usermeta
- Send user activation email when programmatically creating user
- How to implement color picker from wordpress in my plugin?
- How can I run AJAX on a button click event?
- Add async script
- Change default admin page for specific role(s)
- Understanding WordPress functions’ naming conventions
- API to trigger prompt on leaving page
- How to Add a .js file Only in one specific Page Dynamically to Head
- How can I change the frequency of a scheduled event?
- When is it appropriate to put functions on page template vs. functions.php?
- How can i list current author’s categories?
- How to prevent loading of all plugin’s resources?
- How to Structure a New Role/Capability Scheme?
- How to trap “Publish” button to check for meta box validation?
- Pass javascript result to shortcode executer function
- Use js script from one plugin in another plugin
- Problems with removing admin bar
- How to allow Unfiltered HTML in a wordpress multisite install
- What is the Difference between directly call a function and call a function using add_action?
- Making a custom widget that includes a tinymce and works in Site Origin Page Builder
- Looking for callback function after Gutenberg is rendered?
- Call to undefined function get_blog_option()
- Undefined function wp_set_password
- What’s the better way to add an inline script?
- Plugin Uninstall and Deactivate via Options Menu
- Gutenberg: useDispatch is not a function – @wordpress/data included
- Prevent Javascript Facebook SDK Conflicts in plugin
- how to include javascript file and css file in wordpress
- How can I add a CSS rule to edit.php?
- query users by role
- add more custom post types and custom role to the code
- Why is my javascript not invoked in my hooks except wp_head?
- get_posts() not working when accessing with a custom user role
- Is there an event or an other method that tells me the preview is loaded?
- add_rewrite_rule works in themes function php but when moved into plugin it stops working
- Limit role to one plugin [duplicate]
- Where can i find wordpress auto update code flows?
- how to search users by ajax live search
- Do I have to worry about useState causing a re-render?
- Remove unwanted elements for a wp_nav_menu
- My WordPress plugin cannot load my JavaScript file
- mysql_real_escape_string() vs. esc_sql() in WordPress
- Checking for existence of a page by title?
- how to get context information inside my funcion
- Inserting code to HTML view from a pop up initiated from visual view
- Plugin – Make sure jquery is loaded in my settings page plus my JS file
- How to modify files inside wp-includes directory in wordpress
- Fatal error: Call to a member function get_page_permastruct() on a non-object
- wp_get_post_terms Order by not working
- Function/Class to list categories with checkboxes
- should i be checking for jquery before enqueing it in a plugin
- Autogenerate a Table of Contents
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- WordPress multisite,use same cookies across all website?
- unregister_setting() vs delete_option() for plugin update
- How to change WooCommerce loop product title HTML output in single product page and archive page
- Need help about understand api, wp, $ syntax in WordPress plugin script
- How to insert HTML/CSS/JS into my iframe plugin?
- Writing editor content to a file
- Is there a WordPress plugin to design WebGL? [closed]
- Adding tables to dashboard pages programmatically?
- WP 3-way voting system: On to something! Please help!
- How to determine which capability to use?
- How to write a shopping queue line plugin with a queue button?
- Custom Settings Plugin Save foreach checkboxes
- wp.media gallery collection sometimes undefined
- Rerender core Templates with with ToggleControl but it doesnt recognize block type
- function add custom fields to media gallery
- How to use setAttributes outside of the edit function return
- Make visible page only in the trash
- Reading plugin settings in esnext wordpress block
- WordPress: I wanted to use Add rewrite rule multiple times for multiple CPT in my plugin
- Dynamically modify content added to table via javascript
- WordPress Ajax not returning Response
- Add custom parameter for custom user role
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Javascript scroll eventHandler only working when I’m logged in in WordPress
- Replace the WordPress Media Library Uploader
- Remove tag from all posts when publishing new post
- Pass javascript result to shortcode executer function
- Add a Script button in W3 Total Cache plugin not working due to conflicting jQuery version
- Add language localisation to javascript alert?
- How I can give access to my custom plugin for editor roles user?
- What is more secure checking capabilities of user or checking role of user in WordPress plugin development
- WordPress permalink setting
- Dynamic banner for use on external sites
- How can i call from custom fields to the category editor?
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- how can I make content from a plugin hidden when user is logged in? [duplicate]
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- How do I access the contents of WordPress Classic editor in admin area with JavaScript?
- How can create a custom plugin to call my webapi after any registration or membership plugin functionality
- Trouble Importing whatsapp-web.js in a WordPress Plugin Development
- Reinitiate Gutenburg’s blocks using javascript
- how to add contact form 7 shortcode in javascript variable