Skip to content

Commit af7128a

Browse files
authored
gpeb-display-stars-for-rating-fields.php: Added new snippet.
1 parent b11a693 commit af7128a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Entry Blocks // Display Stars for Rating Fields
4+
* https://gravitywiz.com/documentation/gravity-forms-entry-blocks/
5+
*/
6+
add_filter( 'gpeb_entry', function( $entry, $form ) {
7+
foreach ( $form['fields'] as $field ) {
8+
if ( $field->get_input_type() === 'rating' ) {
9+
$selected_value = $entry[ $field->id ];
10+
foreach ( $field->choices as $index => $choice ) {
11+
if ( $choice['value'] === $selected_value ) {
12+
$entry[ $field->id ] = str_repeat( '', $index + 1 );
13+
break 2;
14+
}
15+
}
16+
}
17+
}
18+
return $entry;
19+
}, 10, 2 );

0 commit comments

Comments
 (0)