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

119
Visualizações
Wordpress div text value to PHP Plugin and return different value

I have an embedded interview (like a contact form) on WordPress, I use an on click function to set a text value of a div to the name of that interview's input field that has focus.

I have created a PHP plugin who's purpose is to get the name from WordPress and return a definition (hosted on a Notion database).

I do not know how to grab the value from that WordPress div on click (/value change) and pass it to the PHP plugin to use as a filter (key) so that I may be able to return the definition.

$databaseId = "BBB";
$url = "https://api.notion.com/v1/databases/$databaseId/query"; //api endpoint
$token = 'AAAA';
$version = '2021-08-16';
$contentType = "Content-type: application/json";



// value to be gotten from Wordpress
$dataElementName = $_REQUEST['q'];



// ADD INTEGRATION TO GET VALUE



//post data
$data_array =
['filter' =>
[
"property"=>"DataElement",
"title"=>["equals"=>$dataElementName]
]
];



$data = json_encode($data_array);



//intialize cURL
$ch = curl_init();



curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//below is for posting
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);



curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // Remove when push to wordpress
//auth header notionAPI
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token,
'Notion-Version: '.$version,$contentType));



//output
$resp = curl_exec($ch);



//error check
if($e = curl_error($ch))
{
echo $e;
} else
{
$decoded = json_decode($resp, true);
//var_dump($decoded);
//meaning will be passed to Javascript for Output
$meaning = $decoded['results'][0]['properties']['Meaning']['rich_text'][0]['text']['content'];
echo $meaning;
}

curl_close($ch);

Any advice is greatly appreciated.

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