kennymcnett (@kennymcnett)

Forum Replies Created

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

  • kennymcnett
    Member

    @kennymcnett

    Thanks, Lynq. I’ve seen your posts around these support forums and I appreciate your help and time.

    What I’m really trying to do is apply a filter to the query that creates the loop (so I can filter the list of forums that gets displayed). Any ideas on how to create a new filtered query and/or filter the existing one?

    Perhaps via bbp_has_forums() ?


    kennymcnett
    Member

    @kennymcnett

    Litso, would you mind posting your code? This sounds like what I need to do, but I don’t know how to change the $obj->request like you mentioned works.


    kennymcnett
    Member

    @kennymcnett

    Litso, would you mind posting your code? This sounds like what I need to do, but I don’t know how to change the $obj->request like you mentioned works.


    kennymcnett
    Member

    @kennymcnett

    Thanks for looking at this, jaredatch. Buddypress was overkill for what I needed and was also breaking my custom theme. Some jquery conflict I didn’t want to find.

    For any others out there, I integrated bbPress with s2member permissions successfully. I posted my solution on the s2member forums:

    http://www.s2member.com/forums/topic/a-few-questions-before-i-buy-the-pro-version/#post-13113


    kennymcnett
    Member

    @kennymcnett

    I considered Buddypress, but it’s way more robust than what I’m needing, and installing it was breaking my custom theme (jquery conflict somewhere).

    Thanks for looking at this.

    For anyone else out there, here’s my solution for restricting bbPress access using s2member. In short, this checks if the current user has access to the most distant ancestor of the current page. For example:

    Level 1 Forum/Category > Subforum1 > Subcategory > Subforum2 > Current Topic

    No matter which page they arrive at in the tree, they must have access via s2member to the top-most level. Then it’s a simple matter of assigning a ccap to that Forum, or a membership level.

    1. Include the following in your functions.php file

    2. Include a call to the function in EACH of your bbPress template files BEFORE the template calls for the forum content. Match the HTML structure of the error message to suit your theme. You need to include closing tags for any open divs.

    3. Test!

    /******* bbPress Forum Access *******/

    function checkForumAccess() {

    if(get_post_type() == 'forum' OR get_post_type() == 'topic' OR get_post_type() == 'reply') { // check if user is viewing a forum page. If so, continue.

    //check if they have access to the top-most parent forum/category (both are Pages in wordpress). If not, show the error verbiage. If they have access, continue and show the content like normal

    $parent = array_reverse(get_post_ancestors($post->ID)); // get an array of all the parent pages in order from most distant to closest.

    $first_parent = get_page($parent[0]); //get the first page in the array, which is the most distant parent

    $int = apply_filters(‘the_ID’, $first_parent->ID); //filter the $first_parent to get only the wordpress page/post ID, which is an integer like 49 or 565. store it as a variable $int

    if (!is_page_permitted_by_s2member($int)) { // this is an s2member function. Check if the current user can access the $first_parent, via the stored page/post ID in the $int variable

    // here comes your custom error message. Remember to escape any apostrophes

    echo ‘

    <div>

    <h1 class=”entry-title”>Sorry!</h1>

    <div class=”entry-content”>

    <p>It looks like you don’t have access to this forum.</p>

    <p>If this is an error and you should have access, please contact us here: (contact URL)

    </div>

    </div><!–.postWrapper–>

    </div><!– #content –>

    </div><!– #contentWrapper –>

    </div><!– #primary –>

    ‘;

    get_sidebar();

    get_footer();

    exit; // Important. This prevents the rest of the page (the secure forum content) from displaying

    }

    }

    }


    kennymcnett
    Member

    @kennymcnett

    thanks phrough!!


    kennymcnett
    Member

    @kennymcnett

    Thanks mattsimo and jaredatch. Worked the charm.

    Here are all of the $args and the defaults, FYI (pulled from bbPress core file: bbp-common-template.php)

    // HTML
    'before' => '<div class="bbp-breadcrumb"><p>',
    'after' => '</p></div>',
    'sep' => is_rtl() ? __( '&lsaquo;', 'bbpress' ) : __( '&rsaquo;', 'bbpress' ),
    'pad_sep' => 1,

    // Home
    'include_home' => $pre_include_home,
    'home_text' => $pre_front_text,

    // Forum root
    'include_root' => $pre_include_root,
    'root_text' => $pre_root_text,

    // Current
    'include_current' => $pre_include_current,
    'current_text' => $pre_current_text


    kennymcnett
    Member

    @kennymcnett

    Happy to pay someone for their working solution.

    -Kenny

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