Add the Entry Number to Gravity Forms Email Subjects
Prefixes every Gravity Forms notification subject with the form name and entry ID, so you can find, filter and refer to submissions easily.
Opens WPIDE on
Code
$wpide_gf_subject_format = '[%1$s #%2$d] ';
add_filter( 'gform_notification', function ( $notification, $form, $entry ) use ( $wpide_gf_subject_format ) {
$prefix = sprintf( $wpide_gf_subject_format, $form['title'], (int) rgar( $entry, 'id' ) );
if ( 0 !== strpos( (string) rgar( $notification, 'subject' ), $prefix ) ) {
$notification['subject'] = $prefix . rgar( $notification, 'subject' );
}
return $notification;
}, 10, 3 );
Notes
Change the format at the top; %1$s is the form title and %2$d the entry ID.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.