This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Members Plugin Not Hiding Content

  • Creator
    Topic
  • #23384
    meikam123
    Member

    We are using Members plugin from Justin Tadlock..
    Until last theme update the access role set worked perfectly with the theme blvd template builder.. Since the last update only pages with content from the standard wordpress editor are being hidden depending on roles.. any page that is using the layout builder and synced is not hiding content based on role as desired.
    Please help.. (It seems the layout builder and template sync is not ‘inside’ the content area and is thus not being hidden or restricted as needed)
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #23395
    Jason Bobich
    Keymaster

    Hi,

    Honestly, I’m not really sure how this would have ever worked before? Maybe the Members plugin itself worked differently before? Or were you just now updating from a really old version of the theme?

    Anyway, here’s how to get the the plugin to jive better with the layout builder from your child theme’s functions.php:

    /**
     * Run Members plugin check on custom layouts.
     */
    function my_members_template_config( $config ) {
    
        // Check if Members plugin is installed
        if ( ! function_exists('members_can_current_user_view_post') ) {
            return $config;
        }
    
        if ( $config['builder'] &&  ! members_can_current_user_view_post( themeblvd_config('id') ) ) {
            $config['builder'] = 'wp-private';
            $config['builder_post_id'] = 0;
            $config['featured'] = array();
            $config['featured_below'] = array();
        }
    
        return $config;
    }
    add_filter('themeblvd_frontend_config', 'my_members_template_config', 11);
    
    /**
     * If page is hidden to user, redirect to standard
     * page.php template.
     */
    function my_members_template_redirect( $template ) {
    
        // Check if Members plugin is installed
        if ( ! function_exists('members_can_current_user_view_post') ) {
            return $template;
        }
    
        if ( themeblvd_config('builder') && ! members_can_current_user_view_post( themeblvd_config('id') ) ) {
            $template = locate_template( 'page.php' );
        }
    
        return $template;
    }
    add_filter('template_include', 'my_members_template_redirect');
    #23397
    meikam123
    Member

    Fabulous! Thank you for the swift reply and neat solution!

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

The forum ‘Barely Corporate Responsive WordPress Theme’ is closed to new topics and replies.