문제

anyway to block any user /role(except the admin) to use shortcode? i want to keep some specific shortcode secret. if somehow users come to know, they cant use it. if only admin writes the shortcode it will make changes to site, but if someone else write the shortcode it will be taken as a simple text.

도움이 되었습니까?

해결책

i think this might work with you

function myshortcode(){

$user = wp_get_current_user();
if ( !in_array( 'author', (array) $user->roles ) ) {
    //Run shortcode
}

}

add_shortcode('myshortcode','myshortcode');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 wordpress.stackexchange
scroll top