Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I added a login, logout menu item to a menu with the following code in functions.php. After logout it redirects to the current page. But surprisingly enough, the get_current_user_id method still holds the value of the previously logged in user.

add_filter( 'wp_nav_menu_items', 'asv_add_usermenu_student', 10, 2 );

     function asv_add_usermenu_student( $items, $args ) {

              if (is_user_logged_in() && $args->theme_location == 'top_student_menu') {

                $items .= "<li ><a href='" .wp_logout_url( get_permalink() ). "'>Log Out</a></li>";

            } elseif (!is_user_logged_in() && $args->theme_location == 'top_student_menu') {

               $items .= '<li > <a href="' . wp_login_url() . '?redirect_to='.$_SERVER["REQUEST_URI"].'"/>LOG IN</a></li>';
              }
              return $items;
            }

How to grt rid of it ?

share|improve this question
    
get_current_user_id does not show up anywhere in your code and the user ID does not persist when I test this. There is something wrong somewhere in code not posted. –  s_ha_dum Oct 15 '13 at 13:46
    
@s_ha_dum, get_current_user_id is used in static pages. Let me recheck . –  Istiaque Ahmed Oct 23 '13 at 12:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.