网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

PHP IF标签Wordpress

GG网络技术分享 2025-03-18 16:12 2


问题描述:

I currently have below, its showing that this template can only be accessed by the inspector role. I want to add multi role to this. What would be the best option.

if ( !current_user_can (\'inspector\')) {

get_template_part(\'error\');

exit(0);

}

图片转代码服务由CSDN问答提供

感谢您的意见,我们尽快改进~

功能建议

我目前在下面,它显示该模板只能由督察角色访问。 我想为此添加多个角色。 什么是最好的选择。</ p>

  if(!current_user_can(\'inspector\')){

get_template_part(\'error\');

exit(0);

}

</ code> </ pre>

</ div>

网友观点:

I\'m not entirely sure that I understand the question, but this will show the error template if the user is not an inspector or admin. You can chain as many && together as you need for each role.

if ( !current_user_can (\'inspector\') && !current_user_can(\'admin\')) {

get_template_part(\'error\');

exit(0);

}

标签:

提交需求或反馈

Demand feedback