ThemeFUist (@themefuist)

Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • @themefuist

    Member

    Oops, last function (A bit too much cut and pasting):

    function tfuey_bbp_user_can_view_forum() {

    $forum_id = bbp_get_forum_id();

    if (tfuey_bbp_is_premium_forum($forum_id)) {

    if (is_user_logged_in()) {

    if (current_user_can(‘administrator’) || current_user_can(‘bbp_moderator’) || current_user_can(‘whatever’)) {

    return true;

    } else {

    bbp_get_template_part(‘bbpress/feedback’, ‘no-access’);

    return false;

    } //End if

    } else {

    bbp_get_template_part(‘bbpress/feedback’, ‘no-access’);

    return false;

    } //End if

    } else {

    return true;

    } //End if

    } //End function

    **EDIT: I changed this a bit more. The bbp_get_template_part lines aren’t needed on my theme but are when using twenty ten for some reason (or when I tested at least). If you get two messages saying you don’t have access just remove them i’m not going to figure out why this happened.

    @themefuist

    Member

    How about using a metabox on your edit forum page to specifiy if the forum is premium:

    Add this to your forum functions.php and edit the current_user_can bit at the bottom.

    add_action('bbp_forum_metabox', 'tfuey_bbp_support_forum_metabox');

    add_action('bbp_forum_attributes_metabox_save', 'tfuey_bbp_support_forum_metabox_save');

    add_filter ('bbp_user_can_view_forum', 'tfuey_bbp_user_can_view_forum', 1);

    function tfuey_bbp_support_forum_metabox($forum_id) {

    if (tfuey_bbp_is_premium_forum($forum_id)) {

    $premium_checked = ‘checked’;

    } else {

    $premium_checked = ”;

    } //End if

    echo ‘<hr />

    <p>

    Premium Forum:

    <input type=”checkbox” name=”tfuey_bbp_premium_forum” value=”1″ ‘.$premium_checked.’ />

    </p>’;

    } //End function

    function tfuey_bbp_support_forum_metabox_save($forum_id) {

    if (isset($_POST) && $_POST != ”) {

    update_post_meta($forum_id, ‘_tfuey_bbp_premium_forum’, $_POST);

    } else {

    update_post_meta($forum_id, ‘_tfuey_bbp_premium_forum’, ”);

    } //End if

    } //End function

    function tfuey_bbp_is_premium_forum($forum_id) {

    $tfuey_premium_forum = get_post_meta($forum_id, ‘_tfuey_bbp_premium_forum’, true);

    if ($tfuey_premium_forum == 1) {

    return true;

    } else {

    return false;

    } //End if

    } //End function

    function tfuey_bbp_user_can_view_forum() {

    $forum_id = bbp_get_forum_id();

    if (tfuey_bbp_is_premium_forum($forum_id)) {

    if (current_user_can(‘administrator’) || current_user_can(‘bbp_moderator’) || current_user_can(‘whatever_you_want’)) {

    return true;

    } else {

    return false;

    } //End if

    } //End if

    } //End function

    Leave the forum public and if the premium forum metabox is ticked and the user doesn’t meet the required criteria they will get a “You do not have permission to view this forum” message.

    PS. Untested outside my own site plugin and unnecessary bits have been removed but you should get the gist.

    PPS. Code doesn’t paste too well here apologies if it looks all over the place.

    @themefuist

    Member

    Dunno mate, is jQuery also being called before these two scripts?

    Also have you got any other plugins enabled that use javascript for anything, I’d try disabling them to see if anything changes.

    @themefuist

    Member

    It looks like wpList is set up in:

    **YOUR SITES WP DIRECTORY**/wp-includes/js/wp-lists.js

    Have a look at the page source in your browser and see if the above file is called BEFORE:

    **YOUR SITES FORUM THEME DIRECTORY**/js/topic.js

    @themefuist

    Member

    I noticed this a few weeks ago but never checked if it was fixed:

    https://bbpress.org/forums/topic/possible-bug-ajaxurl-for-favouritessubscribes#post-92000

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