I’m currently working on a laravel app. The same app is already running on wordpress and through the laravel application we are going to add some additional features in original application. The laravel will run on the subdomain.
Here is the thing: On wordpress website, we are publishing different public articles but on the publishing of these articles we need to send an email to either “all employees” of company or “all managers” of the company. The company employees detail is stored and available in laravel.
I was hoping that there’ll be a way through which on article publishing, I will give two options to the user on wordpress: “Send email to employees”/”send email to managers” and on selection of any of the option, email send event will be triggered from my laravel website.
I’ve almost no experience of wordpress. I was trying to google it but couldn’t find any helpful links.
Advertisement
Answer
WordPress works quite different then laravel, and is working with many hooks..
You could monitor post status changes with: https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post
You have to implement the email sending your self inside this hook, And also trigger a webhook against your laravel endpoint.
The publish button in wordpress does not allow you to select who to send an email.., But this can be build with custom fields / meta data on your post. Quite depends on how you would like to implement that.
Unfortunaly WordPress does not work with composer by default therefore you don’t have an easy way to get packages like Guzzle to send your request to your larvel endpoint.
WordPress has some build in methods to do REST calls, see: https://developer.wordpress.org/reference/functions/wp_remote_request/