I've set up the contact form to show only on post pages. I want the contact form to send the message to the post author. So far, I know the variable $emailTo retrieves the email where the message will be sent to.
So I tried:
$emailTo = get_the_author_meta('user_email');
But it is not working. I guess it's because the function is outside the WordPress loop. So, the proper code would be:
$emailTo = get_the_author_meta('user_email', $author_id);
But I don't know how to get the user ID.