• Resolved matthewjpeters

    (@matthewjpeters)


    Hi
    Our scenario is as follows:
    The UM settings are set so that the site is accessible to logged in users only.

    General public can access just a couple of pages which have been added as exceptions to the logged in rule. All good.

    Role type A can view all pages in the site. All good.

    Role type B should be able to see only one page in addition to the ones accessible to those that are logged out. We haven;t been able to work out how to do this without manually setting permissions at a page level which is not practical as there are numerous pages and new ones added regularly.

    Any advise would be gratefully received!

    Thanks
    Matt

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @matthewjpeters

    This requires customization on your end if you want to apply the same restriction to new pages.

    You can use a specific page that has the UM content restrictions( that you want to copy to a new page ). The content restriction data can be found in the wp_postmeta with the meta key um_content_restriction. So you will need this action hook save_post to trigger the code where you need to copy the content restriction.

    Example:

    add_action( 'save_post', 'um_091721_copy_content_restriction', 10,3 );
    function um_091721_copy_content_restriction( $page_id, $post, $update ) {
        // Only want to set if this is a new post!
        if ( $update ){
            return;
        }
         
        // Only set for post_type = page!
        if ( 'page' === $post->post_type ) {
             $copy_from_page_id = 123; // copy settings from this page
             $copy_content_restriction = get_post_meta( $copy_from_page_id,"um_content_restriction", true );
              update_post_meta( $page_id , "um_content_restriction", $copy_content_restriction );
            return;
        }
    }

    Regards,

    • This reply was modified 3 years, 5 months ago by Champ Camba.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    ..This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help… ??

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Block access to all but one page to specific role’ is closed to new replies.