Skip to main content

Wordpress - 修改須強制登入

新增跳轉程式

於主題Theme的functions下新增程式

function admin_redirect() {
if ( !is_user_logged_in()) {
   wp_redirect( home_url('login') );
   exit;
}
}
add_action('get_header', 'admin_redirect');

即可須強制登入才能瀏覽

修改後若無法登入Wordpress

於主機內回復設定/var/www/html/wordpress/wp-content/themes/主題/functions.php