Skip to content

Instantly share code, notes, and snippets.

@mypacecreator
Last active March 1, 2017 08:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mypacecreator/bd3d7f6ae1f465b322ca to your computer and use it in GitHub Desktop.
Save mypacecreator/bd3d7f6ae1f465b322ca to your computer and use it in GitHub Desktop.
WordPress ログイン時にダッシュボードではなくサイトトップへ飛ばす
<?php
//管理者以外はログイン成功後ダッシュボードではなくトップページへ飛ばす
function redirect_login_front_page() {
if( !current_user_can('administrator') ){
$home_url = site_url('', 'http');
wp_safe_redirect($home_url);
exit();
}
}
add_action( 'admin_init', 'redirect_login_front_page' );
//ログイン時のリダイレクト先をトップページへ
function redirect_login_front_page() {
$home_url = site_url('', 'http');
wp_safe_redirect($home_url);
exit();
}
add_action('wp_login', 'redirect_login_front_page');
//ログアウト時のリダイレクト先をトップページへ
function redirect_logout_front_page(){
$home_url = site_url('', 'http');
wp_safe_redirect($home_url);
exit();
}
add_action('wp_logout','redirect_logout_front_page');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment