lundi 5 octobre 2015

Proper way to work with wpdb to get user's firstname

I want to use $wpdb to get user's firstname. I know how to do it with php and mysql query, but I want to use $wpdb.

The problem is that I don't know how to use it. I tried to create simple query to display user fist_name by user_id and than echo it. This is what I ended up with:

$mywpdb1 = $wpdb->get_var( 
    $wpdb->prepare( 
        "SELECT first_name 
        FROM $wpdb->usermeta 
        WHERE user_id = 2", 
        $user->first_name
    ) 
); 
echo $mywpdb1;



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire