Skip Navigation

[Resolved] codice per scelta di tassonomie obbligatoria non va

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 0.53 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 17 replies, has 2 voices.

Last updated by massimoS527 6 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#619759

does not work

#619998

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Massimo

There was a problem with the original code you pasted which I didn't spot.

I did some debugging on your site and then realised the value of the taxonomy fields are an array (with a number value) and not a number, so a small tweak to the code has fixed it.

For reference the full code is like so:

/*  TASSONOMIE OBBLIGATORIE IN AGGIUNGI CREATURE  */
add_filter('cred_form_validate','func_validate_taxonomy_select',10,2);
function func_validate_taxonomy_select($error_fields, $form_data)
{
    //field data are field values and errors
    list($fields,$errors)=$error_fields;

	//validate if specific form
    if ($form_data['id']==348)
    {
        //check my_field value
        if ($fields['creatura-sesso']['value'][0] == '0')
        {
            //set error message for my_field
            $errors['creatura-sesso']='fai una scelta';
        }
          
         //check my_field value
        if ($fields['creatura-specie']['value'][0] == '0')
        {
            //set error message for my_field
            $errors['creatura-specie']='fai una scelta';
        }
          
         //check my_field value
        if ($fields['creatura-vita-assieme']['value'][0] == '0')
        {
            //set error message for my_field
            $errors['creatura-vita-assieme']='fai una scelta';
        }
          
          }
    //return result
    return array($fields,$errors);
}

I tested it and it is now working.

#620100

it works very well