The agent contact form is present in property page (at the bottom or on sidebar) and in agent page can be found in the agent_contact.php file. Here you can find the html code and can change labels or add extra details.

The email sending is happening via ajax. This means that the code is located in both JavaScript files and php files


The email sending is triggered when the send button is pushed. In this case the button has the id agent_submit and the click event is “happening” in
ajaxcalls.js at line 1477

$('#agent_submit').click(function () {
var contact_name, contact_email, contact_phone, contact_coment, agent_email, property_id, nonce, ajaxurl;
contact_name = $('#agent_contact_name').val();
contact_email = $('#agent_user_email').val();
contact_phone = $('#agent_phone').val();
contact_coment = $('#agent_comment').val();
agent_email = $('#agent_email').val();
property_id = $('#agent_property_id').val();
nonce = $('#agent_property_ajax_nonce').val();


*** If you want to add extra fields in the form you would need to “read” those details from the new input elements and send them using .ajax instruction to the php function wpestate_ajax_agent_contact_form().

In the javascript function the forms filled by the user are read

for ex : contact_name = $('#agent_contact_name').val();

and after that sent to the php function
'action' : 'wpestate_ajax_agent_contact_form',
'name' : contact_name,

In case of success ( the transport of data from javscript to php is a success) we clear all the forms and display the message
success: function (data) {
// This outputs the result of the ajax request

if (data.sent) {


The php function wpestate_ajax_agent_contact_form is in ajax_functions.php at line 2714

In there the data sent via javacript is retrived as $_POST variables . For ex the contact name , was sent as “name” (see js code) and now is used as $_POST[‘name’];

After all the data received is checked we compose the message at line 2778 and the email is sent via this line
$mail = @wp_mail($receiver_email, $subject, $message, $headers);

If you make use of the duplicate email feature : “theme options -> social & contact -> Send all contact emails to” the code that send the second email is

$message = $message.' '.__('Message was also sent to ','wpestate').$receiver_email;
wp_mail($duplicate_email_adr, $subject, $message, $headers);

If you need to know more about how Ajax is Working with WordPress you can look over this tutorial :