Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function notification_emails_from_tag( $notification, $form, $entry ) {
- // only change notification to address for this specific notification
- if ( $notification['name'] == 'User Notification' ) {
- $tag = 'Tag Name';
- $args = array(
- 'meta_query' => array(
- array(
- 'key' => wp_fusion()->crm->slug . '_tags',
- 'value' => '"' . $tag . '"',
- 'compare' => 'LIKE',
- ),
- ),
- );
- $users = get_users( $args );
- $emails = array();
- if ( ! empty( $users ) ) {
- foreach ( $users as $user ) {
- $emails[] = $user->user_email;
- }
- }
- // replace the to address with a comma separated list of emails
- $notification['to'] = GFCommon::implode_non_blank( ',', $emails );
- }
- return $notification;
- }
- add_filter( 'gform_notification_1', 'notification_emails_from_tag', 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement