Why is print_r returning $classObj->userObj in several places on site

get_userdata can be, and is, used to get data about different users in different contexts. You seem to expect it to return data about only one “expected” user but I’m not sure why. What you are seeing is the dumped data from several of these different contexts– for example, for the logged in user, for the post author, etc. as get_userdata is used to retrieve information about each of these in turn.

If you look at the Codex, get_userdata can be passed a user ID. If used in that way– say by a plugin or a theme–, it will return data about whatever user ID was passed to it. get_userdata is also used numerous time by the Core to get data about different users– not always the currently logged in user (if that is even what you are asking).

If you expect it always to return the same user then you are using it incorrectly. It is hard to say exactly how as you have posted things so out of context. You might be looking for get_currentuserinfo(), which is also pluggable.

Leave a Comment