WordPress ログアウト時のホームページにリダイレクトさせる

Last Updated: 2020 年 12 月 23 日 댓글

WordPressからログアウトするときのホームページにリダイレクトさせるには、以下の関数を使用することができます。

// Redirect to Home after logout
add_action('wp_logout','go_home');
function go_home(){
wp_redirect( home_url() );
exit();
}

ログアウト後、特定のページにリダイレクトさせたい場合には、次のようなコードをテーマの関数ファイルに追加を試みることができます。

// Redirect to a specific url after logout
add_action('wp_logout','auto_redirect_external_after_logout');
function auto_redirect_external_after_logout(){
wp_redirect('https://example.com/logout');
exit();
}

WordPressでログインした後、またはログアウトした後、特定のページに移動する方法の詳細については、 ここを参照してください。

参考までに WordPress ログインページを変えたい場合は、次の記事で紹介するプラグインを使用すると、簡単にログインページをカスタマイズすることができます。

参照


コメントを残す

コメント