I am trying to display a shortcode of a specific user role. The user role is customer.
global $current_user;
get_currentuserinfo();
if ( user_can( $current_user, "customer" ) ){
echo do_shortcode('[gravityform id="2"]');
}
I am trying to display a shortcode of a specific user role. The user role is customer.
global $current_user;
get_currentuserinfo();
if ( user_can( $current_user, "customer" ) ){
echo do_shortcode('[gravityform id="2"]');
}
You can use the following code:
$user = wp_get_current_user();
if ( in_array( 'shop_manager', (array) $user->roles ) ) { // user role condition
echo do_shortcode('[gravityform id="2"]');
}