Hi @buzztone actually I found a way, using a JS and creating new cform7 new shotcodes.
First I create a shortcode to display some specific CPTs.
wpcf7_add_shortcode('carreras_modalidades', 'createbox_modalidades', true);
function createbox_modalidades($tag){
$name = 'carreras_modalidades';
$options = (array) $tag['options'];
$values = (array) $tag['values'];
foreach ($options as $option) {
if (preg_match('%^(\d*)[/x](\d*)$%i', $option, $matches)) {
$size_att = (int) $matches[1];
$maxlen_att = (int) $matches[2];
}
}
$output = "<select name='".$name."' id='".$name."' onchange='document.getElementById(\"" . $name ."\").value=this.value;' style='min-width:".$maxlen_att."px; max-width:".$maxlen_att."px; border:none; margin-top: 5px; margin-bottom:5px;'><option>Escoja una modalidad</option>";
$terms = get_terms("modalidad");
$count = count($terms);
if ( $count > 0 ){
foreach ( $terms as $term ) {
$output .= "<option value='".$term->slug."'>".$term->name . "</option>";
}
}
$output .= "</select>";
return $output;
}
then using markup inside the form editor to display this new selector shortcode and the two spaces to hide and show other custom selectors.
[carreras_modalidades]
<div id="show1" style="display:none;">
[carreras_diurna]
</div>
<div id="show2" style="display:none;">
[carreras_nocturna]
</div>
Tho show and hide need a custom JS:
/* wpcof7 hide/show animation */
$("select[name='carreras_modalidades']").change(function() {
if ($( this ).val() == 'diurna') {
$("div#show1").show("slow");
$("div#show2").hide("slow");
else if ($( this ).val() == 'nocturna') {
$("div#show1").hide("slow");
$("div#show2").show("slow");
}
});
Ok, this works. But the problem is in the email confirmation.
If I include the shortcodes in the email it works but only show the value of the ones selected, this means the hiden ones are printed as shortcode. ex:
De: [your-name] <[your-email]>
Asunto: [your-subject]
[your-message]
Modalidades:
[carreras_modalidades]
-
[carreras_diurna] [carreras_nocturna]
If the user select diurna and send the form the email show the [carreras_diurna] values but the [carreras_nocturna] obviously is not selected so the email show the shortcode as a text, how can I fix this?