We help IT Professionals succeed at work.
Get Started

wp get_user_meta - get an array or row?

Chris Andrews
Last Modified: 2014-08-20
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...


Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE