Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda