Last active
March 1, 2017 08:46
-
-
Save mypacecreator/bd3d7f6ae1f465b322ca to your computer and use it in GitHub Desktop.
WordPress ログイン時にダッシュボードではなくサイトトップへ飛ばす
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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