How to create a custom login/logout redirect in WordPress




Learn how to redirect your users to a custom page in WordPress. Always work in a child theme and NEVER amend core theme files. If you do – once you update the theme, all your chages will be lost. By working in a child theme, all your customisation is always safe & you’re reducing the risk of breaking your website. To learn about child themes and how to create a child theme, view my other video:

There are multiple plugins which will offer you a custom redirect, but as you know I am not a huge fan of using unnecessary plugins. Especially when this can be done so easily with a couple lines of custom code.

Snippets:

*** LOGIN ***

REDIRECT TO A CUSTOM LINK:
function function_name() {
wp_redirect( ‘ );
exit();
}
add_action(‘wp_login’, ‘function_name’);

REDIRECT TO HOME:
function function_name() {
wp_redirect( get_home_url() );
exit();
}
add_action(‘wp_login’, ‘function_name’);

*** LOGOUT ***

REDIRECT TO A CUSTOM LINK:
function function_name(){
wp_redirect( ‘ );
exit();
}
add_action(‘wp_logout’,’function_name’);

REDIRECT TO HOME:
function function_name(){
wp_redirect( get_home_url() );
exit();
}
add_action(‘wp_logout’,’function_name’);

Official WordPress Developer Guide (Login only):

*** CREDITS ***

Logo & Subscribe Visual –

Intro Music – Heartbeat by LiQWYD Creative Commons — Attribution 3.0 Unported — CC BY 3.0 Music promoted by Audio Library

Background Music – Mrs. Zazzara by Loxbeats Creative Commons — Attribution 3.0 Unported — CC BY 3.0 Music promoted by Audio Library


Fuente – Source

How to create a custom login/logout redirect in WordPress

Necesitas ayuda con wp? Entonces WPVideo es tu sitio.
Encuentra lo que buscas entre cientos de miles de videos y experiencias personales de otros usuarios. Todos los que empezamos con wp deberíamos tener acceso a esta web, ojalá yo hubiera tenido algo así cuando empecé mi camino como webmaster 🙂
Pero ahora quiero y puedo poner esta web a vuestra disposición.
Disfrutadla 😉

Need help with wp? Then WPVideo is your site.
Find what you are looking for among hundreds of thousands of videos and personal experiences of other users. All of us who started with wp should have access to this website, I wish I had something like that when I started my journey as webmaster 🙂
But now I want and I can put this website at your disposal.
Enjoy it 😉

https://www.wpvideo.eu

Publicado en Ecommerce, Plugins, Temas (Themes) y etiquetado , , , , , , .

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *