-
Notifications
You must be signed in to change notification settings - Fork 92
gptos-terms-only-modifier.php: Added snippet to only display terms with the TOS checkbox.
#1051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||||||||||
| <?php | ||||||||||||||
| /** | ||||||||||||||
| * Gravity Perks // Terms of Service // Add a `:terms_only` modifier. | ||||||||||||||
| * https://gravitywiz.com/documentation/gravity-forms-terms-of-service/ | ||||||||||||||
| * | ||||||||||||||
| * Add a `:terms_only` modifier to the {all_fields} merge tag to only display the terms. | ||||||||||||||
| * | ||||||||||||||
| * Instruction Video: https://www.loom.com/share/d69c48bea2d1429ab019310d2bc6c1e6 | ||||||||||||||
| */ | ||||||||||||||
| add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $options, $field ) { | ||||||||||||||
| if ( $field['type'] != 'tos' ) { | ||||||||||||||
| return $value; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| $options = explode( ',', $options ); | ||||||||||||||
| if ( ! in_array( 'terms_only', $options ) ) { | ||||||||||||||
| return $value; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if ( $merge_tag != 'all_fields' ) { | ||||||||||||||
saifsultanc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
| $value = '<ul><li>' . $value . '</li></ul>'; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| $value = wpautop( $field->get_terms( GFAPI::get_form( $field->formId ) ) ); | ||||||||||||||
|
|
||||||||||||||
| return $value; | ||||||||||||||
|
Comment on lines
+24
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential type error in field access Line 24 assumes - $value = wpautop( $field->get_terms( GFAPI::get_form( $field->formId ) ) );
+ $value = wpautop( rgar( $field, 'type' ) === 'tos' ? $field->get_terms( GFAPI::get_form( $field->formId ) ) : '' );Additionally, there's no error handling for the 📝 Committable suggestion
Suggested change
|
||||||||||||||
| }, 11, 4 ); | ||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.