Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
How check if wordpress user ID matches with other data tabale ID and then display data according to matched IDs using PHP

Here is what I am trying to acheive on my wordpress site.

I would like to compare 2 data sources from 1 database. For example when a random wordpress user logs in, I would like PHP to get his user ID and then check if that ID matches with other table's ID and then if they match display content in frontend according to matched ID.

Table 1 is wordpress wp_users and table 2 is a table which has its own id and contains data. Data which table 2 contains is related to wordpress users. Each wordpress has its own data.

I need to display this data in frontend of the website after matching validation is done.

I managed to display data in front end but stuck in comparing two tables.

Here is what I got:

$user = get_userdata($user_id);

$h5p = $wpdb->get_var("SELECT id FROM wp_h5p_results ");

if ($user == $h5p) {
    $total_score = $wpdb->get_var("SELECT score FROM wp_h5p_results ");
    echo "<p>Your Score {$total_score}</p>";
} else {
    echo 'No user with such ID';
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!