Bulk Action send Emails to selected Persons using Advanced Forms for ACF
-
Hi there,
I have a CPT with persons
Among other things, the email address for each person is stored here. In the WP Admin table view, I would like to have the option of sending an email to all previously filtered people as a bulk action. I was able to include a custom bulk action as an additional dropdown.
What would be the code to enable a specific email template for all selected addresses.
I’m missing the knowledge for the following line “foreach ( $post_ids as $post_id ) {
// WHAT WOULD BE THE CODE TO SEND EMAIL VIA advanced_form form=”form_exampleID””
I would be very grateful for a hint.Thanks and Happy Holidays
Here is the code for my bulk action (dropdown):
/*
- Bulk Action Send Email(s) to Persons
*/
add_filter( ‘bulk_actions-edit-product’, ‘register_my_bulk_actions’ );
function register_my_bulk_actions($bulk_actions) {
$bulk_actions[’email_to_eric’] = __( ‘Email to Talents’, ’email_to_talents’);
return $bulk_actions;
}add_filter( ‘handle_bulk_actions-edit-product’, ‘my_bulk_action_handler’, 10, 3 );
function my_bulk_action_handler( $redirect_to, $doaction, $post_ids ) {
if ( $doaction !== ’email_to_eric’ ) {
return $redirect_to;
}
foreach ( $post_ids as $post_id ) {
// Perform action for each post. “WHAT WOULD BE THE CODE TO SEND EMAILS VIA advanced_form form=”form_exampleID””
}
$redirect_to = add_query_arg( ‘bulk_emailed_posts’, count( $post_ids ), $redirect_to );
return $redirect_to;
}add_action( ‘admin_notices’, ‘my_bulk_action_admin_notice’ );
function my_bulk_action_admin_notice() {
if ( ! empty( $_REQUEST[‘bulk_emailed_posts’] ) ) {
$emailed_count = intval( $_REQUEST[‘bulk_emailed_posts’] );
printf( ‘‘ . _n( ‘Emailed %s message to Talents.’, ‘Emailed %s message to Talents.’, $emailed_count, ’email_to_talents’ ) . ”, $emailed_count );
}
} - Bulk Action Send Email(s) to Persons
- The topic ‘Bulk Action send Emails to selected Persons using Advanced Forms for ACF’ is closed to new replies.