0

I want to create a form in my theme that saves a custom post ('type' is 'letter') and then mails it to users from a query (for example users that have a custom key 'user_sub_newsletter' with value 'yes')

I know how to make a user query and how to mail, but I'm not able to make a link between the form and running a PHP function that has all this information.

So the question is: How can I submit a form and run a PHP function where I can store the form values in the database and email users with those form values?

  • Really huge question, but shortly, if you want to connect a php file from your form's action, which will collect all your form data with wordpress, I'll need to make an include of wp-load.php. This file allows you to use all wordpress functionality. require_once("../../../wp-load.php"); Path Depends on your folder structure. And of course after you can validate your data, sanitize it, save it, mail it and so on... – anton Jul 18 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.