Skip to content

Instantly share code, notes, and snippets.

@rafaehlers
Last active August 29, 2023 21:24
Show Gist options
  • Save rafaehlers/c89fafc84998de986c67c8c2f6ccf39e to your computer and use it in GitHub Desktop.
Save rafaehlers/c89fafc84998de986c67c8c2f6ccf39e to your computer and use it in GitHub Desktop.
List Field Merge Tag Modifier to convert text URLs into clickable links
<?php // DO NOT COPY THIS LINE
add_filter( 'gform_merge_tag_filter', 'gv_list_columns', 30, 6 );
function gv_list_columns( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {
if ( $field->type == 'list' && $merge_tag != 'all_fields' && 'urlify' === $modifier ) {
$values = unserialize( $raw_value );
$output = '<ul>';
foreach ( $values as $value ) {
$output .= '<li><a href="'.$value.'">'.$value.'</a></li>';
}
$value = $output.'</ul>';
}
return $value;
}
@rafaehlers
Copy link
Author

Usage: {Listfield:1:urlify} where 'Listfield:1' is the proper Merge Tag for your List field (1 column) containing URLs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment