functions.php에 로그인하여 사용자를 posts-new.php로 리디렉션하는 기능이 추가되어 작동합니다. 그러나 로그인하는 사용자가 컨트 리뷰 터인 경우에만이 작업이 필요합니다. 참여자 및 관리자 모두가 포스트 new.php로 리디렉션됩니다,이 상태에서functions.php의 Wordpress 기능 및 current_user_can()
/** Redirect after login */
function mysite_login_redirect(){
if (current_user_can('manage_options')) {
return 'http://mysite.com/wp-admin/index.php';}
else {
return 'http://mysite.com/wp-admin/post-new.php';}
}
add_action('login_redirect', 'mysite_login_redirect');
: 그래서 나는 다음과 같은 추가. 능력이없는 사용자가 리디렉션 될 수 있도록를 테스트하기 위해 나는 기능을 수정 :
if (!current_user_can('ma ...
내가 기능을 수정하는 경우, 참여자와 관리자 모두의 index.php로 리디렉션됩니다.
기능이 작동하는 것 같지만 관리자에게 'manage_options'기능이 표시되지 않는다는 것을 의미합니다. 동일한 결과를 가진 몇 가지 관리자 전용 기능을 시도했습니다. 이상한가?
필자는 사용자 역할 편집기 플러그인을 사용하고 있지만이 기능을 비활성화하고 동일한 결과로 기능을 테스트했습니다.
저는 Active Directory 통합 및 관리자 메뉴 편집기도 사용하고 있습니다.
if(current_user_can('administrator')){} // only if administrator
if(current_user_can('editor')){} // only if editor
if(current_user_can('author')){} // only if author
if(current_user_can('contributor')){} // only if contributor
if(current_user_can('subscriber')){} // only if subscriber
또는 :
자세한 내용은 대신 내가 '관리자'를 사용하여 시도 여기 https://codex.wordpress.org/Function_Reference/current_user_can –