Hook into transition_post_status
, fetch the users and send an email to all users.
Sample code, not tested:
add_action( 'transition_post_status', 'send_mails_on_publish', 10, 3 );
function send_mails_on_publish( $new_status, $old_status, $post )
{
if ( 'publish' !== $new_status or 'publish' === $old_status
or 'my_custom_type' !== get_post_type( $post ) )
return;
$subscribers = get_users( array ( 'role' => 'subscriber' ) );
$emails = array ();
foreach ( $subscribers as $subscriber )
$emails[] = $subscriber->user_email;
$body = sprintf( 'Hey there is a new entry!
See <%s>',
get_permalink( $post )
);
wp_mail( $emails, 'New entry!', $body );
}
You should probably use the Bcc
field.
Related Posts:
- Attach a Custom Post Type to a Woocommerc product as a variation or add-on [closed]
- Sanitizing post content for use in an email
- Custom post type without editor or revisions – Notify on update?
- Post Via Email to a Custom Post Type
- Want to turn WordPress into a paid subscription directory
- Sending an email when a CPT is saved/updated (NOT when it’s created)
- Email friend for each Custom Post Type posts on a page
- Send email button in custom post type backend
- Notify admin on new submit
- get_post_meta returning no value in custom post type alert email
- Adding the_content() in custom template email
- How can the recipients and content for comment email notifications on a custom post type be changed?
- How to insert data into meta box from another plugin?
- Generate new post from email
- Update Post Status On Woocommerce Payment Complete
- Send email messages after comment was submitted
- Send post changes to set email addresses (not users or subscribers)
- Extending post by email
- See if the email exists or not
- CPT email notification including only new value custom fields
- Send email to author of the post when the custom post status changes to published
- Send mail to author when custom post type is saved
- BCC email to subscribers
- send email to all registered users when post expires
- CPT Metabox with email notification
- Emailing Authors only when a CUSTOM POST TYPE post is published- not when edited later [duplicate]
- How to create a job post by email parsing? [closed]
- Send email on creation of custom post type and use get_post_meta()
- Custom taxonomy wp_query woes.
- WordPress app page not found error for posts with hyphen in permalink
- Where is the sticky post option?
- get_the_tag_list() returns bad links
- Add term list as class
- Filter second dropdown (tax) based on first dropdown (cpt)
- Dump custom post type database
- uploading problem of wordpress theme
- Excluding a Custom Post Type with a specific tag using pre_get_posts
- Custom Post Type Link added to menu won’t show in frontend
- show all custom posts types in home page
- List of users that clicked a ‘Join’ button at single post
- Taxonomy archive 404ing (not term archive)
- Pagination doesn’t function properly for archive of a custom post type set as the front page
- Variable not working in WP_Query
- WP_query – Filter by tax_query and meta_query using multiple select
- Display an authors post on a single page only when they are logged in
- How to group navigation items in the admin panel
- Hide meta box for everything BUT a certain custom post type
- Include php on a specific page template
- Create Array from custom post type to display a slider
- what custom post type this archive belongs to?
- Setting Post Title via Meta Data returns Auto-draft
- Tags not working in my custom post type
- Custom post-type metabox position
- wp_trash_post action hook with custom post type
- Not sure why this template for custom post type posts isn’t displaying anything. What’s missing?
- What’s an efficient way to change the post status of many posts at once?
- Use Pages for Custom Post Type
- Return the name of the post type
- I can’t access custom taxonomy page listing
- Is it possible to load a different sidebar in single.php based on a meta_query filter?
- How to have permalink like domain.com/term/postname?
- List Posts By Custom Taxonomy
- Can variables be used to rewrite a Custom Post Type permalink? [duplicate]
- Creating two loops based on different logic
- How to Echo Metadata Value in Currency Format
- Issue on Working with Metabox – Checkbox to enable Sale Items
- Filter posts by tax (dropdown) and meta value
- How do I amend form data before it is saved for a custom post type
- Archive-posttype.php isn’t loaded
- List of all entries of custom-post-type: Add year-parameter?
- Wp Query with multiple custom tag(taxonomy) by get the terms
- Custom Posts values in custom post overview
- Should I use custom taxonomies or not?
- delete_post_meta() for whole CPT / multiple posts?
- List of child custom post types lists all custom post types
- get comments by current user inside page template
- Move Genesis Single Page/Single Post Title
- Get Specific Template Part if Custom Field is Some Value
- How can Custom Post Type and a page have the same slug?
- Custom filter for main search: how to exclude specific post_type from search results
- Page as Archive page
- Is This Code Efficient – Or is there a better way?
- get post types and plugin order
- Confused about Custom Post Types
- get parent content inside child posts
- Add an Outside Wrapper to my Header and Make it Full Width
- page template for custom post type
- 3 random images from custom post type, each in a div with a diffrent class
- Sortable column containing numeric values for Custom Post Type at WordPress Backend
- How to get specific post meta by title or id
- Listing all post from different custom post type for the logged in user
- Trouble with pagination
- get_category_link() for custom post type does not include custom slug rewrite?
- Page Template Dropdown For Custom Post Types
- Why are some of my custom posts not showing up on my page?
- How to list tags from custom post type attachments?
- How to add editable/dynamic values to dropdown of a Custom Post Type Meta Box
- How to concatenate two separate colums into one?
- make permalink go to a custom single.php file
- Custom Meta Box Causing Error: “Are you sure you want to do this? Please try again.”