Products
GG网络技术分享 2025-03-18 16:12 3
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\"]\');
}
图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议我正在尝试显示特定用户角色的短代码。 用户角色为客户</ strong>。</ p>
global $ current_user; get_currentuserinfo();
if(user_can($ current_user,“customer”)){
echo do_shortcode(\'[gravityform id =“2”]\');
}
</ code> </ pre>
</ div>
网友观点:
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\\\"]\');
}
Demand feedback