Support

Account

Home Forums General Issues Email User within a user field

Solved

Email User within a user field

  • I am hoping someone could point me the right direction on how I can accomplish the following:
    I have a user field on all of my posts to assign users to the posts and I would like to automatically send an email to someone when they are added in the user field. I only want the email to be sent to the new user added in the user field. Any help with this would be greatly appreciated.

  • General outline
    1) Create an acf/save_post action that fires before ACF has saved values (priority < 10)

    2) New field value will be in $_POST['acf'][$field_key]. Get old value of field using get_field(). The new value for a user field will be an array of user IDs.

    3) Compare the old value with the new value to see what users have been added to the array.

    4) Use wp_mail() to send an email to the added users.

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

You must be logged in to reply to this topic.