Calling wp_current_user () in wordpress does not jquery

I am creating a website in WP with the s2member plugin. I used these few lines internally where I used the s2member member code

 $current_user = get_current_user_id(); / get current looged in user ID
    $_SESSION['id']=$current_user;  // put that in session

      

I have requests what is the correct way to establish a session in WP? (I used set_session from above) Results:

  • jquery won't run after uncommenting the code above.
  • The gray bar on top of WP that shows the current logged in user goes blank does not show any logged in user.

    bar while commented code

I thnk that there is another way to establish a session in WP or it doesn't let you do that. Any help in this regard. Thanks to

+3


source to share


1 answer


Not sure about the context where this is used, but two things:



  • 'id'

    too much general argument, used everywhere, try 'u_id'


    It comes to mind because of this WordPress Answer: List of reserved names in $ _POST and $ _REQUEST used by WordPress 3.5

  • $current_user

    - WordPress core global variable, use a different name. And as stated in the linked answer, prefix everything .

+1


source







All Articles