• Resolved oliver1979

    (@oliver1979)


    If I use the members-plugin for the access control of my custom post type, then this works:
    add_filter('members_enable_testtype_content_permissions', '__return_true');

    But as soon as I load a custom single template for this custom post type:

    
    add_filter('single_template', array($this, 'load_course_template') );
    [...]
    public function load_course_template($template) {
       global $post;
       if ( 'testtype' === $post->post_type && locate_template( array( 'single-testtype.php' ) ) === '' ) return plugin_dir_path( __FILE__ ) . '/theme/single-testtype.php';
       return $template;
    }
    

    Then the access control is ignored.
    Can I somehow include the access control of the members-plugin in this single-template, or is there another solution?

    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author Caseproof LLC

    (@caseproof)

    Hi @oliver1979

    ​I apologize for the delay in response.

    It sounds like the issue could be with what you have in that custom template. By default, Members only protects content, excerpts, and comments. For example, access is determined for the content by filtering the_content. If you’re not implementing these things in your template, Members won’t have any effect. You can have a look at members/inc/functions-content-permissions.php to see how this is done. You can also use other Members functions for access logic. The members/inc/functions-users.php file contains a number of functions that may help.

    Best

Viewing 1 replies (of 1 total)

The topic ‘Custom post type and single_template’ is closed to new replies.