Enable categories and access control on pages

Hi.

How to enable Categories and Access Control on PAGES?

I’ve just installed the Groups plugin and the Restrict Categories add on to restrict access to certain pages to users from distinct groups. I wish that if the user is not logged in, than receive the login page. If the user is logged in and dont’s belong to the categorie that the page is restricted for, than receive a massage.

Thank you

One Response to Enable categories and access control on pages

  1. Eugen Bleck January 14, 2020 at 11:45 pm #

    Hi Marcelo,

    Happy new year and thanks for using our groups’ plugin.

    To enable categories on pages please add the following code snippet to your themes function.php:
    function add_category_to_pages() {
    // Add category metabox to page
    register_taxonomy_for_object_type(‘category’, ‘page’);
    }
    // Add to the admin_init hook of your theme functions.php file
    add_action( ‘init’, ‘add_category_to_pages’ );

    The above hook, will help enable categories on your WP pages and allow you to select categories for pages.

    With respect to showing the user a login page if not logged in, you could use one of either methods,

    First, you would need to download and install our Groups 404 Redirect Plugin, which would allow you redirect any pages protected by our Groups plugin.

    1. Once installed head to Groups -> Groups 404 then select Redirect to the WordPress login and check that you have the Redirect Status Code to your desired status code, then save changes.

    2. Another possibility is to create a page and add the following shortcode to it,
    [groups_non_member group="Registered"]
    [groups_login]
    [/groups_non_member]
    [groups_member group="Registered"]
    You are connected!
    [groups_logout]
    [/groups_member]

    Then get the page id and visit Groups -> Groups 404 then select Redirect to a page or post, after which the id of the page should be entered in the field Page or Post ID and check that you have the Redirect Status Code to your desired status code, then save changes.

    You can find more on the shortcodes used above here in our documentation . Also you can read more on Access control here.

    I wish you a fun and awesome day ahead.
    Kindest regards,
    Eugen-Bleck.

Only authorized members can comment on this topic.

Log in

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share