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?
- How to include PHP files in plugins the correct way
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- Why does WordPress add 0 (zero) to an Ajax response?
- How to include jQuery and JavaScript files correctly?
- 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
- What is an alternative method to the WordPress private _doing_it_wrong() function
- Change default admin page for specific role(s)
- How to provide translations for a WordPress TinyMCE plugin?
- Understanding WordPress functions’ naming conventions
- Add Custom User Capabilities Before or After the Custom User Role has Been Added?
- Can I use the wp media uploader for my own plugin?
- How-to implement admin Ajax inside an admin WP_List_Table?
- API to trigger prompt on leaving page
- Customizing the 3.5 “Add Media” popup (Backbone.js)
- Test to see if jQuery or Prototype is queued by another plugin?
- Using OOP plugin’s methods throughout the website
- Include third party Javascript library which is not included in WordPress
- How to Change the Entire WordPress Admin panel Look and Feel?
- jQuery in header or footer
- Hook the Keydown Event in the TinyMCE Post Editor
- function triggered by “manage_users_custom_column” filter not working
- How to Add a .js file Only in one specific Page Dynamically to Head
- How can I change the frequency of a scheduled event?
- WordPress plugin how to run function when button is clicked
- lodash dependency in a Gutenberg plugin
- wp_localize_script $handle
- When is it appropriate to put functions on page template vs. functions.php?
- Shortcodes, output buffering, and WordPress functions
- How can i list current author’s categories?
- Determine which theme location a wp_get_nav_menu_items is for
- How to prevent loading of all plugin’s resources?
- How to Structure a New Role/Capability Scheme?
- When to check if a function exists
- How to trap “Publish” button to check for meta box validation?
- Checking for existence of a page by title?
- Pass javascript result to shortcode executer function
- The changes I make to an external JS file of my WP plugin are only applied after I clear my browser’s cache
- `wp_set_script_translations` with `wp.i18n` does not return translated strings in simple plugin
- How to add more than 1 user role to sub-menu pages
- Use js script from one plugin in another plugin
- Dynamically Override Fancy Title
- Problems with removing admin bar
- Problem with `wp_mail()`
- How do I only load js on the post-new.php and post.php pages in admin?
- Calling a function from functions.php in custom page/ blog post
- creating elements/innerblocks via rangecontrol
- How to allow Unfiltered HTML in a wordpress multisite install
- Check if I am in the Admin Panel (wp-admin)?
- 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()
- What is the difference between current_page_parent and current_page_ancestor?
- Plugin development: is adding empty index.php files necessary?
- Undefined function wp_set_password
- What’s the better way to add an inline script?
- Does add_filter work outside functions.php
- What function to hook for changes made in status and visibility of a post
- Can’t get JS code to work with shortcode
- How to restrict plugin’s sub-menu pages to admin/subscribers?
- How to not let a user with a new role edit users that have administrator role?
- Execute plugin for specific user role(s) only
- how to use preg_replace for wordpress video?
- How do I add a javascript file to all admin pages via a plugin?
- Plugin Uninstall and Deactivate via Options Menu
- Gutenberg: useDispatch is not a function – @wordpress/data included
- Make a list with header and subtext in Gutenberg blocks
- Gutenberg – What is the best way to save/update post meta?
- Prevent Javascript Facebook SDK Conflicts in plugin
- How to Load Plugin JS in theme’s footer section
- how to include javascript file and css file in wordpress
- How can I add a CSS rule to edit.php?
- Print WordPress username id inside JavaScript
- query users by role
- wp_enqueue_script + wp_enqueue_style Since When
- Mixing Regular Javascript With jQuery in a Plugin
- 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 to plugin function code move to theme function.php ? I’ve tried below code but not working [closed]
- How can i add insertion point between inner blocks in my custom block like core blocks
- WordPress simple ‘Hello World’ plugin – problems
- How do I access the contents of WordPress Classic editor in admin area with JavaScript?
- get_term_by() returning null on plugin
- How to get the value entered in the input field in wordpres
- Remove default wordpress roles
- How react js and other Javascript Technologies works on WordPress plugin?
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- Get all users from role and add to dropdown (select) – wordpress, 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
- Insert meta-description into Yoast-SEO input-field via JavaScript
- Reinitiate Gutenburg’s blocks using javascript
- how to add contact form 7 shortcode in javascript variable