Site icon Hip-Hop Website Design and Development

Solely admin ought to run wordpress plugin shortcode

I’ve created a easy plugin that locks down content material for customers not logged in and it’s working effective. Nonetheless any consumer on a multi-author website might use the identical quick code in his submit to lock down content material too. I are not looking for this to occur.

How might I limit this performance to directors solely?
This present code thows up a deadly error:Deadly error: Name to undefined perform wp_get_current_user()

public perform check_user_role() {
  if(current_user_can( 'activate_plugins' )) {
        return true;
    }
}

I then meant to make use of this technique in my class constructor to find out if the add_shortcode() perform ought to run. Any clues how I ought to go about implementing this shall be appreciated.