Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add Shortcode
- function restrict_content( $atts , $content = null ) {
- // Attributes
- $atts = shortcode_atts(
- array(
- 'role' => 'administrator',
- ),
- $atts
- );
- $user = wp_get_current_user();
- if ( in_array( $atts['role'], (array) $user->roles ) ) {
- return $content;
- } else {
- return false;
- }
- }
- add_shortcode( 'restrict_content', 'restrict_content' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement