Page 1 of 1

dynamically set 'required' status of registration field

PostPosted: September 15th, 2011, 10:51 am
by halifaxious
I've run into what might be considered an s2member bug. To whit: when a member is demoted the information that had been in fields only applicable to higher levels seems to be lost. This means that the member must re-enter any higher level fields when they are re-promoted.

To work around this issue, I'd like to make fields that are optional for level 0 and required for levels >1 (in my case, it would be a set of address fields).

So far as I can determine, a custom registration field is either required for all the levels it applies to or optional for all the levels it applies to. I watched the video on how to dynamically set registration fields, but I can't determine which hook I should be attaching my function to or which values I need to change. Is there a reference somewhere to the structure of the $_field variable and/or other data structures I'll need to manipulate?

Re: dynamically set 'required' status of registration field

PostPosted: September 23rd, 2011, 11:24 am
by halifaxious
To clarify the above, I'd like to know a) if it is possible and b) how to make registration fields required for one level and optional for another level.

Thanks,
Jen

Re: dynamically set 'required' status of registration field

PostPosted: September 24th, 2011, 10:42 pm
by Cristián Lávaque
Thanks for finding that! I'm going to let Jason know so he can find a solution to it.

Re: dynamically set 'required' status of registration field

PostPosted: September 27th, 2011, 8:30 pm
by Jason Caldwell
Thanks for your inquiry.
halifaxious wrote:To clarify the above, I'd like to know a) if it is possible and b) how to make registration fields required for one level and optional for another level.

Yes, this is possible, you just need to create two fields, each with a different ID. One will be required at Level #1, another is optional at Level #2 in the following example. Both fields ask for the same type of input and use the same label, but are configured in two different ways. ( click to enlarge )
SNAG-0008.png

If a Member is demoted, Custom Fields are not lost. However, if you (or they) edit their Profile after having been demoted, and fields which were present at the previous level no longer apply at the new demoted level, this is when the data loss will occur ( i.e. upon the data being saved again, minus the previous fields which no longer apply ). Not exactly a bug, but I see why you question this after a re-promotion. I'll see what can be done to improve this in the future.