SHARE
TWEET

Untitled

a guest May 25th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter( 'wp_nav_menu_items', 'tk_child_add_loginout_link', 10, 2 );
  2.  
  3. function tk_child_add_loginout_link( $items, $args ) {
  4.  
  5.     if ( is_user_logged_in() && $args->theme_location == 'top-bar-right' ) {
  6.  
  7.         $current_user = wp_get_current_user();
  8.         $message = sprintf( esc_html__( 'Welcome %s', 'tokoo' ), $current_user->display_name );
  9.         $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>';
  10.  
  11.     } elseif ( !is_user_logged_in() && $args->theme_location == 'top-bar-right') {
  12.  
  13.         $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>';
  14.  
  15.     }
  16.  
  17.     return $items;
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top