Wordpress notification custom field - wordpress

I need to add mail notification on Wordpress.
I've a custom post type with a date custom fields.
When today is the date in custom field for one of the custom post, I need to send mail with all informations from this custom post.
Do you know how I can do this notification ?
Thanks a lot !

You have to create a new function in your WP, in functions.php for example, to scroll through all "custom post type" and compare if the current date is the same as the "custom post type and if so, send the mail (You can use the php mail function).
Then you have to talk to your hosting provider and you have to add in cron this function and that you run it every minute.
I hope it helps you, if you need anything else do not hesitate to ask.

Related

is there anyway to send notification of new Post is published in wordpress to another page of same website?

I'm creating a wordpress plugin in which i want that if new post is published the notification gone on another page of same wordpress website.
Thanks
There is a few ways todo this. But I would do it this way.
When you create a post, you add a post_meta to that post that tells that this page is new.
Then you have an cronjob or something that is running an wp_query that are searching for all posts that have that post_meta. And when it finds the new post/posts it either clear that post_meta or set it to false.
And then on the page that you wanted to display it somehow, use that cronwork to update that page or something like it.
Hard to describe more when I don't know what that other page should do with the information about the new post

Wordpress notification based on advanced custom fields data

I have posts on my website (custom post type) of which the content is filled from advanced custom fields input. The post also include a date field and an email address field. What I like to do is send automatic notifications to the email address when the date is today. Or even better 3 days before the date of today.
I've read some articles about using Wordpress php mail function but don't know where to start. Any points in the right direction are appreciated.
So you can use the Wordpress wp_mail() function.
https://developer.wordpress.org/reference/functions/wp_mail/
Make sure you are using a SMPT plugin so your email doesn't end up in spam.
https://wordpress.org/plugins/wp-mail-smtp/
That should get you started, not sure how I would set up the job to send the mail, by I would definitely use wp_mail().

How to run a woocommerce email notification function from inside a custom php script

I am trying to run something similar to this function.
wp_new_user_notification( $new_user_id );
this function above works already but I would like to use the woocommerce function. As that includes a better email template. I know I can tick it on in the woocommerce admin. But I am using my own form script for the user registration. Which doesn't trigger the woocommerce email notification.
I found this function somewhere in the woocommerce code but I have no idea how to use it.
woocommerce_created_customer_notification.
Please help thanks!
Yes you are right woocommerce includes a better email template, but this is not a good practice to use them in php script for registration script.
You can use your custom code for new user registration email and change you email template as you wish.
For second option there are many plugins available for new user email.
like :https://wordpress.org/plugins/welcome-email-editor/

Save custom post fields value before Woocommerce email send

I have an issue regarding emails sent by Woocommerce.
I have multiple custom fields, set up using the ACF plugin, for Wooocomerce orders. These fields contain additional info that should be visible in the emails sent to the user.
But for some reason I can't get them to save before the email is send and thus the email is empty of those values. Only after I click resend email are the values visible.
I tried prioritizing the action hooks using the Prioritize Hooks plugin but to no avail. Tried multiple things in order to prioritize.
I have the Woocommerce emails set up in the template that I use and get retrieve the custom fields like this:
$fields = get_field('fields', $customer_order->ID);
How can I get this to work properly? Any help is appreciated.
you need to store your data before send the email, so you need to find the correct hook.
If i'm not wrong the before_woocommerce_pay hook is your answer check here for more woocommerce hooks

Wordpress - update functions.php from dashboard

I'm sure this isn't possible but I thought I would ask.
In my functions.php file I have a wp_mail function that sends an email to moderators when posts are made.
This email is sent to number of different address - these addresses might change.
I thought it would easier to set these email addresses in the WP Dashboard something like on custom page and then have functions.php update with the new emails.
Is this possible?
Yes, this is possible.
With out getting into the specific coding details you would need to store the different email addresses in the database.
You could tie in advanced custom fields to the wp_mail function to pull the different address from a list. That way you could skip building a page in the dashboard to display the addresses.
Regardless some custom coding would need to happen in the mail function to grab the data from advanced custom fields.

Resources