Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

347
Vistas
Hide reCaptcha response in the front-end

I need to rearrange conditions to hide the reCaptcha response in the front end, as shown in the image below:

enter image description here

I have the following function:

function my_contact_form_generate_response($type, $message){
 
    global $response;
 
    if($type == "success") $response = "<div class='alert alert-primary' role='alert'>{$message}</div>";
    else $response = "<div class='alert alert-danger' role='alert'>{$message}</div>";
    }

reCaptcha response

$request = "https://www.google.com/recaptcha/api/siteverify?secret={$secretkey}&response={$recaptchaResponse}&remoteip={$userIp}";
$content = file_get_contents($request);
$json = json_decode($content);

Conditionals are:

if ($json->success == "true") {
  
  
          //validate email
      if(!filter_var($email, FILTER_VALIDATE_EMAIL)) 
        my_contact_form_generate_response("error", $email_invalid);
      else //email is valid
      {
        //validate presence of name and message
        if(empty($name) || empty($message)){
          my_contact_form_generate_response("error", $missing_content);
        }
        else //ready to go!
        {
          $sent = wp_mail($to, $subject, strip_tags($admin_email), $headers);
          if($sent){
              my_contact_form_generate_response("success", $message_sent); //message sent!
              $_POST = array();
          } 
          else {
             my_contact_form_generate_response("error", $message_unsent); //message wasn't sent 
          } 
        }
        
      
      }
  
} else {
  
  my_contact_form_generate_response("error", $recap_invalid);
}

How can I re-arrange my conditions to hide the failed ReCaptcha error message and only display it if it fails after submitting the form?

Thank you in advance.

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda