I am working on a real estate website.
Once somebody submits a listing, there is a details page which shows all infromation about a property.
Now, i have a "Contact the property owner" button, that lets anyone to send a message to post owner.
After clicking on that button, there shows a popup where you can type your message, name, subject and so on. The popup is controlled by a plugin.
The mail is being send using wp_mail function. The problem is i can't get post author email becouse popup creates its own post id, that is different from property post id.
I need to get the id of the property page, not the id of the popup.
The thing is, my code has to be written in the popup.php file.
My code is:
global $post;
$author_id=$post->post_author;
$to = get_the_author_meta( 'user_email' , $author_id );
wp_mail(
$to,
$subject,
$message,
$headers
);
do_action('un_admin_notification_sent', $id, $params, $message);
}
Unfortunately, the mail is not being send, becouse $to is empty - it is using the id of the popup, when i want to be using the id of the current page (that is in the background behind the popup).
Any help would be much appriciated.