Title: Removing shortcode usage for specific user role
Last modified: April 21, 2019

---

# Removing shortcode usage for specific user role

 *  [9march](https://wordpress.org/support/users/9march/)
 * (@9march)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/removing-shortcode-usage-for-specific-user-role/)
 * Hi,
 * Can i please get some help with removing the use of shortcodes for specific users
   roles, I want only author to be able to use shortcodes. If that is not possible,
   How can i strip shortcodes or remove them from the is_home conditional tag?
 * Thanks,

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/removing-shortcode-usage-for-specific-user-role/#post-11452613)
 * Do you have custom roles?
    If not, isn’t the author role the least capable role
   to be able to publish? Any other roles less capable have to have their pages 
   published by someone else, who can remove shortcodes.
 * What is the actual problem you are trying to solve?
 *  Thread Starter [9march](https://wordpress.org/support/users/9march/)
 * (@9march)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/removing-shortcode-usage-for-specific-user-role/#post-11464536)
 * Hi,
 * Sorry for the delayed response, I must have missed the email. Yes i have a custom
   role that was created by the frontend posting plugin i use and whenever i create
   a post as subscriber or any other role except administrator, The shortcodes show
   up all the time. Sorry for the misunderstanding, I meant to say, I want to remove
   the usage of shortcodes for all user roles except administrator.
 * Thanks,
 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/removing-shortcode-usage-for-specific-user-role/#post-11467195)
 * You could use a filter on the content either when it is saved or when it is output,
   and look at the author and call `strip_shortcodes()`.
    [https://developer.wordpress.org/reference/functions/strip_shortcodes/](https://developer.wordpress.org/reference/functions/strip_shortcodes/)
 *  Thread Starter [9march](https://wordpress.org/support/users/9march/)
 * (@9march)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/removing-shortcode-usage-for-specific-user-role/#post-11467755)
 * Hi,
 * Thanks for your great help, I received this code from my theme providers.
 * add_action( ‘init’, ‘remove_my_shortcodes’,20 );
 * function remove_my_shortcodes() {
    if( !current_user_can(‘administrator’)){ remove_shortcode(‘
   myshortcode’ ); } }
 * Regards,
    -  This reply was modified 7 years, 1 month ago by [9march](https://wordpress.org/support/users/9march/).
    -  This reply was modified 7 years, 1 month ago by [9march](https://wordpress.org/support/users/9march/).
 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/removing-shortcode-usage-for-specific-user-role/#post-11471233)
 * Well, that might do what you want, however, it is a bit rough.
    The `current_user_can`
   function should be used with a capability (like `edit_posts`), not a role. Here’s
   the list: [https://codex.wordpress.org/Roles_and_Capabilities](https://codex.wordpress.org/Roles_and_Capabilities)
 * And since the `init` action happens on both the front end and the admin, it is
   always run. And all it does is make the shortcode handler not process the shortcode.
   The actual shortcode is still in the post.
    My suggestion to use `strip_shortcodes`
   removes the actual characters of the shortcode from the content of the post.
 * You can find the sequence of the basic actions here:
    [https://codex.wordpress.org/Plugin_API/Action_Reference](https://codex.wordpress.org/Plugin_API/Action_Reference)

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Removing shortcode usage for specific user role’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [Joy](https://wordpress.org/support/users/joyously/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/removing-shortcode-usage-for-specific-user-role/#post-11471233)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
