Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Per emailed question, utilizing the example in my blog post "User Dropdown List & Custom Notification Routing in Gravity Forms" for multiple fields that have the custom 'user-emails' CSS class to email multiple people
* Change the sent to email address in the notification
* @author Joshua David Nelson,
// Route to user address from drop down list, update the '1' to the ID of your form
add_filter( 'gform_notification_1', 'route_user_email_notification', 10, 3 );
function route_user_email_notification( $notification, $form , $entry ) {
// Create an array to store email addresses for notification
$emails = array();
// Go through each field to find the user-emails fields
foreach( $form['fields'] as &$field ) {
// Make sure this is the right field
if( $field['type'] != 'select' || strpos($field['cssClass'], 'user-emails') === false )
// Pull out the user id selected, by the field id and the $entry element
$field_id = (string) $field['id'];
$user_id = $entry[ $field_id ];
// set the email address to send the email to
if( !empty( $user_id ) ) {
$email_address = get_the_author_meta( 'user_email', $user_id );
// Just double checking the author meta is an email address
if( is_email( $email_address ) ) {
$emails[] = $email_address;
// If we have some emails in our array, turn it into a comma-separated list and update the notification
if ( ! empty( $emails ) ) {
$email_to = implode(', ', $emails );
$notification[ 'to' ] = $email_to;
return $notification;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment