Skip to content

Instantly share code, notes, and snippets.

@rafaehlers
Created March 26, 2021 21:21
Show Gist options
  • Save rafaehlers/2e0a1ada81e4ac380b19216cd0c7b6fe to your computer and use it in GitHub Desktop.
Save rafaehlers/2e0a1ada81e4ac380b19216cd0c7b6fe to your computer and use it in GitHub Desktop.
<?php // DO NOT COPY THIS LINE
// Merge Tag Modifier to pull only the first character of a string. Usage {Field:1:firstword} inside a custom content field
add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value ) {
if( 'all_fields' !== $merge_tag && 'firstword' === $modifier ) {
$value = force_balance_tags( wp_specialchars_decode( substr( htmlentities( $value ), 0, 1 ) ) );
return $value;
}
return $value;
}, 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment