Trying to get Authors ID

Question

I m trying to show the user Score on a Quiz in their posts, I m adding this inside the Single.php loop:

    global $wpdb;

$user_id = the_author_ID();
$table_name = "MYWP_quizresults";
$sql = "SELECT * FROM ".$table_name." WHERE user_id = ".intval($user_id);

$result = $wpdb->get_results($sql);  

 if(!empty($result))                      
{    
    foreach($result as $row){  

        echo "ID: ". $row->user_id. " Name: ". $row->user_name;
    }

}
0
, , , Philip Kav 3 years 2020-04-02T20:51:22-05:00 0 Answers 97 views 0

Leave an answer

Browse
Browse