If statement 使用快捷码添加条件按钮
我正在尝试使用If statement 使用快捷码添加条件按钮,if-statement,shortcode,If Statement,Shortcode,我正在尝试使用[按钮]短代码添加几个按钮。我想要实现的是,第一个按钮button-01显示给所有用户,而另一个按钮button-02只显示给“author”用户角色 这是我的密码: function shortcode_button() { global $current_user; get_currentuserinfo(); // Show this button to ALL return '<a class="button" href="http
[按钮]
短代码添加几个按钮。我想要实现的是,第一个按钮button-01显示给所有用户,而另一个按钮button-02只显示给“author”用户角色
这是我的密码:
function shortcode_button() {
global $current_user;
get_currentuserinfo();
// Show this button to ALL
return '<a class="button" href="http://example.com/01">FOR ALL</a>';
// Show button to AUTHORS ONLY
if ( user_can( $current_user, "author" ) ) {
return '<a class="button" href="http://example.com/02">FOR AUTHORS ONLY</a>';
}
}
add_shortcode( 'button', 'shortcode_button' );
功能快捷码_按钮(){
全局$当前用户;
获取_currentuserinfo();
//向所有人显示此按钮
返回“”;
//仅向作者显示按钮
if(user\u can($current\u user,“author”)){
返回“”;
}
}
添加_短代码('button','shortcode_button');
当以作者身份登录时,我可以看到第一个按钮,但第二个按钮没有显示
我错过什么了吗?是否有endif也许是代码>语句