Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'wp_nav_menu_items', 'tk_child_add_loginout_link', 10, 2 );
- function tk_child_add_loginout_link( $items, $args ) {
- if ( is_user_logged_in() && $args->theme_location == 'top-bar-right' ) {
- $current_user = wp_get_current_user();
- $message = sprintf( esc_html__( 'Welcome %s', 'tokoo' ), $current_user->display_name );
- $items .= '<li class="menu-item"><a href="'. esc_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ) .'"><i class="ec ec-user"></i>' . $message . '</a></li>';
- } elseif ( !is_user_logged_in() && $args->theme_location == 'top-bar-right') {
- $items .= '<li class="menu-item"><a href="' . esc_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ) . '"><i class="ec ec-user"></i>' . esc_html__( 'Log In', 'tokoo' ) . '</a></li>';
- }
- return $items;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement