hi @cristhianbh98
there is no such function yet.
Hi Alexander, thank you for you answer and your time.
I can see that in the add-on Wp-testing — Export there is a section where you can query users that did a specific test, I know beacuse I purchased that add-on, so I want to know if in that section you did a query to thee database or use a function to display the users.
Great plugin btw.
Regards.
Hi, I could solve my problem, if anyone want to know how do this, just copy the next code.
function wpt_user_has_submit($test_id = 0, $user_id = 0) {
global $wpdb;
$has_submit = false;
$row = $wpdb->get_results( "SELECT * FROM wp_t_passings WHERE test_id = $test_id AND respondent_id = $user_id LIMIT 1");
if(count($row) > 0) {
$has_submit = true;
}
return $has_submit;
}
You can call the function providing the user id and the test id you want to query, this return a boolean whether the user has submitted a test or not.
A little bit more optimal version:
function wpt_user_has_submit($test_id = 0, $user_id = 0) {
global $wpdb;
return $wpdb->get_var("SELECT count(*) FROM wp_t_passings WHERE test_id = $test_id AND respondent_id = $user_id") > 0;
}
Also pls note, that table name can be different as of prefix and can be not wp_t_passings.