Created
          March 26, 2021 21:21 
        
      - 
      
- 
        Save rafaehlers/2e0a1ada81e4ac380b19216cd0c7b6fe to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?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