[wp-trac] [WordPress Trac] #46019: Themes using get_users() appear to change the current user

WordPress Trac noreply at wordpress.org
Thu Jan 17 11:31:47 UTC 2019


#46019: Themes using get_users() appear to change the current user
-------------------------------+------------------------------
 Reporter:  lordmatt           |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Users              |     Version:  5.0.3
 Severity:  minor              |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------
Changes (by lordmatt):

 * severity:  normal => minor


Comment:

 You are right. I had second thoughts after I filed this ticket. I went
 back to the theme where I last saw the issue. It is used on wordpress.com
 so I assumed the code was solid.

 I had created a watch array which checked the current user ID at the start
 and end of the template. It was different. By adding that a few more times
 I was able to see that `get_users()` is, as you say, innocent. The change
 happened after `foreach ( $all_users as $current_user ) {...}`

 I did not find any documentation on it but I suspect that maybe
 `$current_user` is a global? Which is odd as `$current_user` is the
 variable used in code examples. Changing this var throughout the theme to
 `$my_current_user` removed the bug. I have left a support request for the
 theme author(s) so they can apply my changes.

 Should `$current_user` be a global - or at least something that can be
 changed within the loop?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46019#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list