All of WP’s built-in roles have subscriber capabilities. You’re basically checking here, “if the current user has at least subscriber capabilities”. If you want to isolate only the subscribers, you can check for the absence of a higher capability. If you are just using built-in roles, the next higher role of Contributor has edit_posts
and delete_posts
capabilities by default.
if(!current_user_can('edit_posts')) {
// display your message
}
As far as adding content this way, admin_init
is a pretty early hook, so depending on your content and how it is styled, it may cause some layout quirks. You mentioned you don’t want to use a dashboard widget, so you might want to look into other hooks, or perhaps add an options page that subscribers can view with your custom content.
Related Posts:
- what is correct way to hook when update post
- Enforcing password complexity
- Does an activated plugin automatically mean its methods are available to other WP functions?
- How to set custom cookies before output
- Check php version before theme activation
- Getting the action’s tag name within the action
- How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?
- Action ‘save_post’ not working for quick edit
- Can i check if user is doing any ajax request?
- add_meta_boxes action with refresh on save
- Use wc_enqueue_js only on specific pages – nested add_action
- How to Remove a Filter from the Admin List Table?
- Insert post without actions/hooks
- Hooking new functions to actions + passing parameters
- Find variables available at a given hook
- Why do filters/actions require an argument count?
- Appending meta value onto post content in WordPress during save_post
- save_post vs post_updated
- Delete option value from array using update_option()
- How to access function from outside of a class within this class in WP plugin?
- Extend a class of a plugin
- action hook wp_head higher priority as all other plugins/hooks
- How to use return in my custom function instead of echo
- WP_cron won’t trigger my action
- How to add custom post meta to default blog post?
- Adding Default Settings to Theme My Login plugin
- action is not called after a php request
- Remove an action hook within a Class
- Ajax not working es expected (Returns 0)
- How to pass arguments to add_action() or retrieve return value of called function?
- Custom Form Processing Issue
- add_action shortcut?
- Is it acceptable to treat a filter like an action?
- Ajax – Call to undefined function get_option()
- add element with add_action to posts from a specific category ID
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Trying to place a custom field after the total section in the checkout page in woocommerce
- Set meta field to publish date + 2 weeks
- Adding widgets to my plugin page instead of WordPress dashboard
- action theme mailchimp subscriber fields
- Adding function to Genesis genesis_header [closed]
- Modify custom field input data before creating a new post
- Error call_user_func_array() expects parameter 1 to be a valid callback when using image_size_names_choose
- jQuery code not working when included in functions.php
- add_action taking an array with the 2nd argument?
- Should `wp_login` be used since it’s deprecated?
- How to show a users bio on a page
- Override a function defined in wp-includes/comment-template.php
- Nested “do” and “add” Actions is possible?
- Change order of custom submenu link in WP Admin?
- How to catch wordpress post ID when it’s published
- WordPress redirect redirecting too many times or not at all
- Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?
- How to pass argument to add_action while the method is inside a class?
- Display attribute on shop page after the title
- Action Hook Inside WordPress Plugin Shortcode
- Dynamically adding filters
- Woocommerce custom Plugin in wordpress [closed]
- How to pass hook variable to function?
- Editor capabilities – admin_init
- Change image data durgin upload
- WordPress Post Block Element not properly parsed with the_content filter
- Remove an action created by a Gravity Forms add-on
- remove_action from parent theme using child theme functions.php
- Use PHP Class in WordPress functions
- WordPress How do I pass a variable from one add_action to another?
- I want to hide “sold by” on certain pages with id page 43
- Get original value in save_post action hooka
- How do I remove an action hook inside a class that is called by another class?
- add_action in wp_head accessible from class
- in the post admin, is it possible to make the post title input disabled using php?
- Hook into all password resets in WordPress and get password before hashing?
- Why should I need to add init action to include PHP file to WordPress Plugin?
- remove_action() not working in page template – Genesis
- Unable to pass arguments to function used in add_action
- wordpress form action page not found
- Add two or multiple functions in WordPress Post or Page
- Submit to itself don’t work
- WordPress HTML Helper
- At what point during a typical request does the $wpdb object become available?
- How does add_action ‘comment_post’ work?
- Highlight posts currently being edited on multiple editor site?
- Custom action on comment post
- WordPress Plugin Receive a Link
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- How to add custom checkout field in user details mail template
- Cannot modify header information – headers already sent
- Fix incorrect related posts code snippet
- Why a class property becomes empty?
- How to change wp-admin and wp-login urls
- How to sort custom sortable column by custom table value
- Is there a hook that I can use when a fatal error occurs?
- Using shipped version of jquery
- What’s the uses of wp_cache_set() or wp_cache_add()?
- get_the_title() gets printed out twice
- What does this mean in wordpress? Easy question
- Add Codepen animation as Preloader to WordPress
- Responsive loop with 3 columns inside row then 2 columns
- Cron job -many duplicate posts
- why is markup routinely placed in functions in wordpress?