• Resolved myideasforsite

    (@myideasforsite)


    Hello. Can I change pipe symbol for select maybe with help of some hook

    Like

    “option|value” to “option : value”

    for example

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter myideasforsite

    (@myideasforsite)

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

    Thread Starter myideasforsite

    (@myideasforsite)

    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);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change pipe symbol for select separator’ is closed to new replies.