0

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.

1 Answer 1

1

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
}
2
  • 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.
    – Enoque
    Commented Jun 18, 2013 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.
    – Jen
    Commented Jun 18, 2013 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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