• Resolved Jon

    (@freshyjon)


    Is there a function or something I can implement, so that logged-out users do not have access to ANY “Poll” post type? I see I can add this on a per-post basis, but I need to prevent access to any existing or future posts from the Poll post type.

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

    (@champsupertramp)

    Hi,

    You can try the following code:

    
    add_action("template_redirect","um_prevent_accessing_posts_types");
    function um_prevent_accessing_posts_types(){
         if( ! is_user_logged_in() && in_array( get_post_type(), array( 'poll','posts' ) ) ){
               wp_redirect( um_get_core_page('login') ); exit; 
         }
    }
    

    Regards,

    Thread Starter Jon

    (@freshyjon)

    Perfect. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Restrict access to entire post type?’ is closed to new replies.