latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

SET custom capability based on the category?

Home Forums Community Forum SET custom capability based on the category?

This topic contains 2 replies, has 1 voice. Last updated by  Bryan Chalker 3 years, 3 months ago.

Topic Author Topic
Posted: Tuesday Sep 10th, 2013 at 5:04 pm #59416

Is there a way to set the custom capability of an entire category, rather than individual pages/posts?

I have 5 CC needs:
– one
– two
– three
– four
– five

All access ONLY their own content and will be individual sign-ups/monthly fees. I know I can assign the “one”, “two”, etc. names to the “Require Custom Capabilities” section of a posting, by typing them in.

I want to:
– Assign a post to a category (“one”, “two”, etc.), and have THAT assign the CC.

Is this possible using PHP conditionals or assignment?

Thanks

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Thursday Sep 12th, 2013 at 3:08 pm #59498

This is how I assumed it would be handled, but it isn’t working.

add_action ("template_redirect", "TGW_Access_Conditionals");

function TGW_Access_Conditionals()
    {
        if (is_category("Banjo") && !current_user_can("access_s2member_ccap_banjo"))
            {
                header ("Location: ". S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                exit ();
            }
        if (is_category("Guitar") && !current_user_can("access_s2member_ccap_guitar"))
            {
                header ("Location: ". S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                exit ();
            }
        if (is_category("Mandolin") && !current_user_can("access_s2member_ccap_mandolin"))
            {
                header ("Location: ". S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                exit ();
            }
        if (is_category("Bass") && !current_user_can("access_s2member_ccap_bass"))
            {
                header ("Location: ". S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                exit ();
            }
        if (is_category("Dobro") && !current_user_can("access_s2member_ccap_dobro"))
            {
                header ("Location: ". S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                exit ();
            }
}
  • This reply was modified 3 years, 3 months ago by  Bryan Chalker.
  • This reply was modified 3 years, 3 months ago by  Bryan Chalker.
Posted: Monday Sep 16th, 2013 at 10:48 am #59617

no ideas?

Viewing 2 replies - 1 through 2 (of 2 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.