I have created a website in Wordpress. In that , I has a page create_invoice, where I have added html that takes user input in the form.
I have set up the logic so that this page is only displayed to logged in user.
What I want is, when user submits the form, I want to send a mail to the logged in user with a pdf of the invoice.
I have generated code to send the email. But I cannot get email of the logged in user via javascript.
I have checked on many sources online , like Wordpress Codex and stackoverflow, but all suggests functions of php like get_current_user_id() etc.
But I cannot figure out how to use php in my code, and even when I display the userinfo using php , i get notting.
<?php $userinfo = get_current_user_id(); echo '.$userinfo.' ?>
Can any one please help me out in this. Or can I use some sort of rest api to get logged in user info.
This is how you can get the current Wordpress user in PHP:
and this is how you can put it into Javascript: