Change pipe symbol for select separator

[ad_1]

Standart code with pipe seems to be not working. Default theme, no plugins except CF7

found solution

function change_cf7_pipes($tag){
	if ($tag['basetype'] != 'select'){return $tag;}
	$values = [];$labels = [];
	foreach ($tag['raw_values'] as $raw_value){
        $raw_value_parts = explode('|', $raw_value);
		if (count($raw_value_parts) >= 2){
			$values[] = $raw_value_parts[1];
			$labels[] = $raw_value_parts[0];
		}else{
			$values[] = $raw_value;
			$labels[] = $raw_value;
		}
	}
	$tag['values'] = $values;$tag['labels'] = $labels;
	/*Optional but recommended:
		Display labels in mails instead of values
		You can still use values using [_raw_tag] instead of [tag] */
	$reversed_raw_values = array_map(function($raw_value){
		$raw_value_parts = explode('|', $raw_value);
		return implode('|', array_reverse($raw_value_parts));
	}, $tag['raw_values']);
	$tag['pipes'] = new \WPCF7_Pipes($reversed_raw_values);
	return $tag;
}
add_filter('wpcf7_form_tag', 'change_cf7_pipes', 10);

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer