Showing/hiding custom fields depending on the form, when forms are for the same level

Hello,

I have 2 different forms for the same access level, and I need to show or hide some custom fields depending on which form is showing. Normally I’d just make the custom fields only show at certain member levels and then give the forms 2 different levels, but I need the fields to exist at all levels (as I’ll be editing them with PHP even if they aren’t shown).

I would use different templates for the forms, but the template files merely contain a %%custom_fields%% substitution variable that gets filled in by a function. Said function has hooks, but playing with ws_plugin__s2member_custom_field_gen and ws_plugin__s2member_during_custom_field_gen_after, neither of them seem to receive any variables that would indicate which form is being filled out!

So, any ideas?

Edit: hmm, actually, after more testing it looks like custom fields do exist for users of all levels, even if they’re only set for certain levels? At least, I can set and get them. I assume that won’t cause any problems?

Set these fields “non mandatory” and then hide them with CSS (put it in footer with “wp_footer” hook) for different customers. You will need to find a good way to determine who must see them.

To your question: not a problem to read and save values of custom fields with custom code.