• Hi,

    I am trying to limit some content to certain users.
    I have set up a custom field (called “type_of_user”) and this field is a multi-option checkbox field.

    I only want to allow users who selected one specific option (of the 6 checkbox options) to see this particular content.
    (The content itself is part of a normal wordpress post.)

    So far, I can only see how to restrict content to whole/entire user levels, or whole/entire custom fields, but I cannot see how to restrict to users based one one specific checkbox option (part of a custom field)

    Thanks

    https://www.ads-software.com/plugins/s2member/

Viewing 6 replies - 1 through 6 (of 6 total)
  • I don’t think there is a way to do that without customization. You would need somehow to associate your check box with a custom capability.

    If you have the Pro version, you could use the Pro form to give you a series of checkout options, each of which would automatically be associated with whatever user role or ccap you choose.

    Thread Starter LRowe

    (@lrowe)

    Thanks for yout reply ??
    Yes, I think it does require some customisation/coding. I have worked out how to restrict content to just 2 “levels” of s2 membership. However, I think that (part of?) the issue might be that checkboxes/drop-down-menu/multi-option field data is held as an array (as it’s clearly not an entire field) and I can’t work out how to restrict for just part of the array ??

    Now you’re doing it by user levels, I don’t really see a problem. Just use the Pro form checkout options, and you should be fine.

    Thread Starter LRowe

    (@lrowe)

    Hi,
    Thanks. No, I don’t want to do it user levels – as I said in my original post. I said, I can see how to do it by user levels but that’s NOT what I am after. I want to restrict part of a post to those Users who have selected a particular option on a multi-option custom field.

    Having looked, I don’t think the pro forms will do it.
    It will require some form of coding (that follows on from restriction by users or is similar to it). I am looking for pointers on how to code that.

    Thanks

    I know what you said originally. But then you said you had it down to two user levels. That would work easily, because all you’d be doing would be moving your “multi-option fields” from where you currently have them to the checkout options. Then it would be plain sailing.

    In any event, you’ll need to look at Restriction Options -> Simple Shortcode Conditionals

    Thread Starter LRowe

    (@lrowe)

    Hi,
    Thanks both, yes, I realise it needs customisation.

    It think it goes further than the Simple Shortcode Condititionals, though – Using the shortcode conditionals allowed me to the restrict to 2 user levels, for example, as per the kb article https://www.s2member.com/kb/simple-shortcode-conditionals/#example-3
    However, I don’t actually want to do this, per se. I want to restrict part of a post to those Users who have selected a particular option on a multi-option custom field, REGARDLESS of their user level.

    Yes, indeed it does need customisation

    I found an article on how to use the S2Get shortcode to list a particular option on a multi-option custom field, which the fact that this data is stored as an array. However, I want to RESTRICT content to a particular option on a multi-option custom field, not merely list it on a post/page.
    https://www.s2member.com/forums/topic/get-values-from-custom-field-multiple-select/

    I think the custom code requires something along of using the array (because that’s how the multi-option custom field data appears to be stored)?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to restrict content based on custom field/multi-option, checkbox field’ is closed to new replies.