Skip to content

Commit 7874b6c

Browse files
authored
gpls-use-entry-for-each-user-rule-message.php: Added new snippet to use the current user entry to replace message merge tag variables.
1 parent 5092a61 commit 7874b6c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Limit Submissions // Use the latest user entry to replace merge tag
4+
* variable for the limit message, when rule is set to `Each User`.
5+
* https://gravitywiz.com/documentation/gravity-forms-limit-submissions/
6+
*/
7+
8+
//Update string `45` to your form ID.
9+
add_filter( 'gpls_limit_message_45', function( $message, $form ) {
10+
if ( ! rgpost( 'gform_submit' ) ) {
11+
$search_criteria['field_filters'] = array(
12+
array(
13+
'key' => 'created_by',
14+
'value' => get_current_user_id(),
15+
),
16+
);
17+
$total_count = 0;
18+
$results = GFAPI::get_entries( $form['id'], $search_criteria, array(), array(), $total_count );
19+
if ( $total_count > 0 ) {
20+
$message = GFCommon::replace_variables( $message, $form, $results[0], false, false, false, 'html' );
21+
}
22+
}
23+
24+
return $message;
25+
}, 10, 2 );

0 commit comments

Comments
 (0)