Skip to content

Instantly share code, notes, and snippets.

@JustinSainton
Created January 27, 2016 23:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JustinSainton/e79e53dc6d02903bc3e7 to your computer and use it in GitHub Desktop.
Save JustinSainton/e79e53dc6d02903bc3e7 to your computer and use it in GitHub Desktop.
Use existing Gravity Forms notification on non-form data
<?php
$form_id = 12; // Or whatever form ID has the notificaiton you're after
$form = GFAPI::get_form( $form_id );
$notification = end( $form['notifications'] ); // Just an easy way to get the notification I wanted. YMMV.
$lead = array(
'id' => wp_generate_password( 64, true, true ), // Normally, this would be the Lead ID. Not necessary for us.
'form_id' => $form_id,
'source_url' => 'https://site.com/',
'status' => 'active',
'1.3' => $args['first_name'], // YMMV on these args - set them to whatever your form sets them to be.
'1.6' => $args['last_name'],
'2' => $args['user_email'],
'4' => $args['term_id'],
'5' => $args['user_pass'],
'1.2' => '',
'1.4' => '',
'1.8' => ''
);
GFCommon::send_notification( $notification, $form, $lead );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment