wp get_user_meta - get an array or row?

I'm trying to make my wordpress script as efficient as possible.

Right now, I'm doing this:

$author_id is set.


$author=get_the_author_meta( 'user_login',$author_id);

$author_name=get_the_author_meta( 'first_name',$author_id);

$authLevel = get_the_author_meta( 'user_level',$author_id);


Is there a way to use an array in that so I can do it with one call to mysql?

Or.. would it be more efficient to call the whole row (get_user_meta($author_id)) rather than ask for three particular things, and then pull them out of that?

Or is the way I am already doing it the most efficient?

Likewise, is there a way to change this so it's one mysql access?


$overall = $wpdb->get_var("SELECT overall FROM adshare WHERE author = '$author'"); //get number
$wpdb->query("UPDATE adshare SET overall = overall+1 WHERE author = '$author'"); //add one to number in db


I would need $overall to give me the pre-update number though...


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott MadeiraCommented:
If the get_user_meta() function returns all the info you need, it would be more efficient as one database call uses less resources than three separate calls.  The only time that may not be true is if your single query had a lot of table joins in the query as joins are fairly expensive operations.

I assume that you need the value of $overall somewhere else in your code and that is why you are making the two queries.  The second query is independent of the first one.  If you don't need the pre-value of $overall then you don't need to make the first query.  If you want the value of $overall then you need to do the two queries.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
St_Aug_Beach_BumAuthor Commented:
Got it, thank you very much!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.