Support

Account

Forum Replies Created

  • This tries to send the email but to no recipient

    add_action( 'acf/save_post', 'my_acf_save_hook_email', 5); function my_acf_save_hook_email( $post_id ) { 
    
    // bail early if no pds_project_manager 
    if( empty('pds_project_manager') ) { 
    return; }
    
    // Get the value of the ACF field 
    $project_managers = get_field('pds_project_manager', ''); 
    // Create an empty array to store the emails 
    $emails_to_send = array(); 
    
    // Loop through the project managers 
    foreach ($project_managers as $project_manager) { 
    // Get the user data 
    $user_data = get_userdata($project_manager); 
    
    // Check if the user already exists in the array 
    if (!in_array($user_data-> user_email, $emails_to_send)) { 
    // Add the user to the emails to send 
    $emails_to_send[] = $user_data->user_email; } } 
    // Send emails to the users 
    foreach ($emails_to_send as $email_to_send) { 
    // Send the email 
    wp_mail($email_to_send, 'You Have Been Added To A Project', 'You have been added to a project. Please check the project page for more information.'); } }
  • I had gone in a different way but I am back to this, I know it’s been awhile. Here is what I have come up with, but it isn’t working, any ideas?

    add_action( 'acf/save_post', 'my_acf_save_hook_email', 5); function my_acf_save_hook_email( $post_id ) { 
    
    // bail early if no pds_project_manager if( empty($_POST['pds_project_manager']) ) { 
    return; }
    
    // Get the value of the ACF field $project_managers = get_field('pds_project_manager', ''); 
    // Create an empty array to store the emails $emails_to_send = array(); 
    
    // Loop through the project managers 
    foreach ($project_managers as $project_manager) { 
    // Get the user data 
    $user_data = get_userdata($project_manager); 
    
    // Check if the user already exists in the array 
    if (!in_array($user_data->ID, $emails_to_send)) { 
    // Add the user to the emails to send 
    $emails_to_send[] = $user_data->user_email; } } 
    // Send emails to the users 
    foreach ($emails_to_send as $email_to_send) { 
    // Send the email 
    wp_mail($email_to_send, 'You Have Been Added To A Project', 'You have been added to a project. Please check the project page for more information.'); } }
  • Here is the code I have tried entered correctly.

    add_action( 'acf/save_post',  
    'my_acf_save_post', 10 );
    function my_acf_save_post( $post_id ) {
    // Get value of field 1
    $value1 = get_field( 'pds_project_manager',$post_id );
     // Get value of field 2 
    $value2 = get_field( 'architect', $post_id );
    
    update_field( 'project_user_email_select', $value1 . $value2, $post_id );
    }
  • How could I modify the priority on this to get the new value right as it is updated? I have an email notification that is sent right when the architect_notification field is changed but it includes the old value and not the new value. Is this an issue with get_field?

Viewing 5 posts - 1 through 5 (of 5 total)