How to hide custom fields on registration page conditionally based on ccaps?

I need to do the following (I’m using S2 Member Pro) with the registration forms (not profile forms):

  • I have two “logical” user types for Level #0 (let’s call them type-A and type-B)
  • These two user types get different ccaps set in two different Level #0 forms
    (i.e. I’m using the WordPress shortcode for the forms; so just two different versions of the s2 pro forms shortcode each with a different custom ccaps="…" set)
  • I have a set of custom fields. Some apply to both user types, some only to user type-A, and some only to user type-B
  • I’d like to be able to conditionally set which fields are present in the Registration form based on the ccaps that are going to be assigned upon registration using that particular form.

I was hoping that a filter was available like the one that can be used to specify which custom fields to show/hide on the profile form (as seen in this kb article). I was unable to find anything in the codex.

I dug into the code for the registration template and see that it doesn’t provide any filters like the profile form for showing/hiding custom fields; so it looks as though I’m out of luck doing this an easy way (you know, without having to add a filter and modify the core s2 member files).

Is there a best practice to implement what I need? Am I stuck creating two separate form templates for each user type and then directing users of each type to the custom template forms? Or is there an easier way?

The method I use to set s2Member custom fields based on anything other than Membership Level is custom templates. Note that you’ll need to generate a Pro-Form with all of your s2Member custom fields and then use that code to replace the Custom Fields section of your custom template. You’d have to write significant custom code to do this any other way.

Maybe can hide the files you not need at the moment by CSS? And some [s2If conditions] on the page to set the right CSS settings…

Thank you Pat and Krum for both of your replies.

I’ve found other references in Google search results to doing it as Krum has suggested and using CSS rules, but I think that is kind of a hack and would prefer the fields to not be present/visible in the html form source at all and not just hidden via CSS visibility rules.

I prefer what Pat has recommended and that’s the path I’m going to head down.

Thanks again for replying with options.