Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using the Advanced Custom Fields for custom fields in the User Profile. I use conditional logic to display one of between four fields, each field will be displayed according to a radio field option previously clicked.

In this case only one option would can be sent. But, when the user update your profile all four fields are being sent.

The conditional logic in this case is only serving to show or hide.

Some tip on how to improve this?

I appreciate any help.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This is a limitation of how showing/hiding fields works with Javascript, and how Wordpress saves meta-data. Probably the best way to handle it is to use the same type of switch logic where you want to use the data. something like this:

switch ( get_field('radio_field') ) {
  case 'first_option':
    // get data from your first field
    break;
  case 'second_option':
    // get data from your second field
    break;
  //etc
}
share|improve this answer
    
Thank you guiniveretoo. The issue is that I can not modify the scripts javascript of plugin. I believe that, if a field-x is conditional the field-y, should only be sent if the field-y was marked, and in this case, the field-x is being sent even though checked field-z. –  enoquenroll Jun 18 '13 at 15:50
1  
you're right, you can't edit the plugin's javascript (at least not easily) and I don't think that should be the solution at all anyway. Just check which radio box was selected, then use that to get the value that you need on the output side of things. –  guiniveretoo Jun 18 '13 at 15:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.