WordPress.org

Ready to get started?Download WordPress

Forums

Private BuddyPress
Only exclude SOME pages (how-to) (5 posts)

  1. pealo86
    Member
    Posted 2 years ago #

    I'm shocked this hasn't been incorporated into the plugin considering the amount of requests I've just read in this forum.

    Alas, it is not hard to achieve. Simply modify the example code from the plugin FAQs in order to unblock a page by its ID number:

    // unblock a page by id
    function make_page_visible($visibility) {
        global $bp;
        if (is_page(26))
            return false;
        return $visibility;
    }
    
    add_filter('pbp_login_required_check', 'make_page_visible');

    http://wordpress.org/extend/plugins/private-buddypress/

  2. frostdawn
    Member
    Posted 2 years ago #

    Thanks for the post, however trying the above, I got the following error:
    Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in C:\xampp\htdocs\wordpress\wp-content\plugins\private-buddypress\private-buddypress.php on line 88

    I then tried to add the option of a page filter to the exception rules already defined in the source such as:

    function LoginRequired() {
    // No login required if homepage is excluded
    if ( true == $this->options->exclude->homepage && is_front_page() )
    return false;

    // No login required if terms is excluded
    if ( true == $this->options->exclude->terms)
    return false;

    // No login required if registration is excluded
    if ( true == $this->options->exclude->registration && ( bp_is_register_page() || bp_is_activation_page() ) )
    return false;

    // No login required if blog pages are excluded
    if ( true == $this->options->exclude->blogpages && bp_is_blog_page() )
    return false;

    // No login required if blog pages are excluded
    if ( true == $this->options->exclude->page && bp_is_page('mypage') )
    return false;

    // Login required
    return apply_filters('pbp_login_required_check', true);
    }

    While that block of code didn't throw any errors, it didn't exclude the page as expected either.

  3. frostdawn
    Member
    Posted 2 years ago #

    I've since discovered that documents added to the media gallery are NOT protected by this plugin. So if you have information that can be imparted by an attachment, hardcode that link, and it will not be covered by the privacy plugin. Just an FYI for anyone that comes along and tries to customize this plugin.

  4. frostdawn
    Member
    Posted 2 years ago #

    I also attempted to add an exception to the LoginRedirect before the loggedin check is performed. I didn't get the syntax just right, but it could prove to be an alternative way to get something past the privacy filter. Provide the URL to a page you don't want protected to the exception rule and if that URL is hit, it should exit out of the if loop in the LoginRedirect function.

  5. mw128
    Member
    Posted 1 year ago #

    I tried this and it worked: first, in the WP Admin under Settings-->Reading, under BuddyPress Protection you turn on (check) the setting to Exclude Blog Pages from protection. Then, in private-buddypress.php on line 146, you change it to:

    // No login required if blog pages are excluded
    if ( true == $this->options->exclude->blogpages && bp_is_blog_page() && !is_page(106))
    return false;

    Where 106 is the page id of whatever page you want to be private. I think you can also use an array

    !is_page(array(42,'about-me','Contact'))

    though I didn't try that yet.

    Kind of a backwards way, but it's a way of protecting some pages and not others.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic