get_userdata(): should I be worried about too many db queries?
I am thinking about the number of queries my site is doing on certain pages. In particular I notice that in many cases I need to get the user_login field in order to do something. For example, on a forum thread I need it for two things:
1. in order to call bp_core_get_avatar() to display the profile picture
2. in order to form the link that a user would click to send the post author a message
Something like this…
$author_id = get_post_author_id( $post_id );
$author = get_userdata( $author_id );
$author_loginname = $author->user_login;
Should I be worried about the new sql query I’m doing every time I use get_userdata()? Is there a more efficient way to get the user_login?
You must be logged in to reply to this topic.