Format List Field Value as Ordered List instead of default Unordered List

Hi there!

I am attempting to modify the output of the list field values for my custom notifications using the gform_merge_tag_filter. I want to change the list format from an unordered list to an ordered list by changing the “

” tags to “
” tags.

I’ve tried modifying the snippet from this thread (I want to format a list field values in a custom notification [RESOLVED]), but it doesn’t seem to work, most likely because I’m not implementing it right.

From how I understand it, I need to target the list merge tag that has my own custom modifier (:numbered), then find any “

    ” tags and replace them with or “
      ” tags.

      add_filter('gform_merge_tag_filter', function ($value, $merge_tag, $options, $field) {
      	if ( $field->type == 'list' && $modifier == 'numbered') {
      		$newvalue = $value;
      	    // change opening tag
      		$find = '#<ul>#';
      		$replace = '<ol>';
      		$newvalue = preg_replace($find, $replace, $newvalue);
              // change closing tag
      		$find = '#</ul>#';
      		$replace = '</ol>';
      		$newvalue = preg_replace($find, $replace, $newvalue);
      		return $newvalue;
      	} else {
      		return $value;
      }, 10, 6 );

      Am I thinking this through correctly? Is this the wrong implementation?

      This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.