Created
January 9, 2018 16:11
-
-
Save webprogramacion/2823307f6b5f941a3d153f2e0fd06f57 to your computer and use it in GitHub Desktop.
Menú de inicio de sesión en 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
function add_login_logout_register_menu( $items, $args ) | |
{ | |
if ( $args->theme_location != 'secondary-menu' ) | |
{ | |
return $items; | |
} | |
if ( is_user_logged_in() ) | |
{ | |
$current_user = wp_get_current_user(); | |
$items .= "HOLA " . esc_html( $current_user->user_login ) . " | "; | |
$items .= ' | |
<a href="' . wp_logout_url() . '">CERRAR SESIÓN</a> | |
'; | |
} | |
else | |
{ | |
$items .= ' | |
<a href="/login”>INICIAR SESIÓN</a> | | |
'; | |
$items .= ' | |
<a href="/registro">CREAR CUENTA</a> | |
'; | |
} | |
return $items; | |
} | |
add_filter( 'wp_nav_menu_items', 'add_login_logout_register_menu', 199, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment