Alex Stine (@alexstine)

Forum Replies Created

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

  • Alex Stine
    Participant

    @alexstine

    Looking back on it now, I never did have the development time to make this work before I discontinued CloudSearch, but this looks to be the best code if anyone’s brave enough to try it in the future. 🙂

    function exclude_topics_in_private_forum() {
    $forum_id = bbp_get_forum_id();
    $query = bbp_get_all_child_ids($forum_id, 'post');
    foreach($query as $key => $q) {
    if(is_private_forum($forum_id) ) {
    update_post_meta($key, 'exclude', 1);
    } elseif(!is_private_forum($forum_id) ) {
    delete_post_meta($q, 'exclude');
    }
    }
    }
    add_action('bbp_new_forum', 'exclude_topics_in_private_forum' );
    add_action('bbp_edit_forum', 'exclude_topics_in_private_forum' );

    Thanks for the help.


    Alex Stine
    Participant

    @alexstine

    Hello,

    I started to work on the code and then got my bill. That’s when I instantly stopped using CloudSearch. It’s a good starting place though. If I ever revisit CloudSearch in the future, I’m coming back for the code.

    Thanks for the help.


    Alex Stine
    Participant

    @alexstine

    Hello,

    Okay, I like something that doesn’t query the DB to much. Would something like this work? I’m somewhat new to arrays and post_meta, but trying to learn fast.

    /*Remove all topics from Amazon CloudSearch if topic is in a private forum*/
    /*Private Forums are added as an integration through a plugin*/
    /*Amazon CloudSearch is added as integration through a plugin*/
    function exclude_topics_in_private_forum() {
    $forum_id = bbp_get_forum_id();
    $query = bbp_get_all_child_ids($forum_id, 'post');
    foreach($query as $q) {
    OR
    foreach($query as $key => $q) {
    if(is_private_forum($forum_id) ) {
    update_post_meta($q, 'exclude', 1);
    OR
    update_post_meta($key, 'exclude', 1);
    } elseif(!is_private_forum($forum_id) ) {
    delete_post_meta($q, 'exclude');
    }
    }
    }
    add_action('bbp_new_forum', 'exclude_topics_in_private_forum' );
    add_action('bbp_edit_forum', 'exclude_topics_in_private_forum' );

    How does that look? Any suggestions?

    Thanks.


    Alex Stine
    Participant

    @alexstine

    Hello @robin-w,

    I still need to get this straight. Maybe something like this would work?

    /*Remove all topics from Amazon CloudSearch if topic is in a private forum*/
    /*Private Forums are added as an integration through a plugin*/
    /*Amazon CloudSearch is added as integration through a plugin*/
    function exclude_topics_in_private_forum() {
    $forum_id = bbp_get_forum_id();
    $query = bbp_has_topics( array( 'post_parent' => $forum_id) );
    foreach($query as $q) {
    if(is_private_forum($forum_id) ) {
    update_post_meta($q, 'exclude', 1);
    } elseif(!is_private_forum($forum_id) ) {
    delete_post_meta($q, 'exclude');
    }
    }
    }
    add_action('bbp_new_forum', 'exclude_topics_in_private_forum' );
    add_action('bbp_edit_forum', 'exclude_topics_in_private_forum' );

    It is important to note that I am using custom plugins to pull off a lot of the private forum abilities that way I can control user access better. I think the code snippet above will do it. Thoughts?

    Thanks.


    Alex Stine
    Participant

    @alexstine

    Hello @robin-w,

    If I’m not mistaken, doesn’t this come with bbPress by default? Not sure what template it is actually in right now, but if you open up a single forum, you should see it. For example this URL.

    Plugins

    Thanks.


    Alex Stine
    Participant

    @alexstine

    Hello @robin-w,

    It’s this text at the top and bottom of single forums.

    “Viewing 4 topics – 1 through 4 (of 4 total)”

    Thanks.


    Alex Stine
    Participant

    @alexstine

    Hello @robin-w,

    I’m not using a default bbPress function to hide the topics. I’m using a custom plugin to handle the hiding of topics so members who are participants have a choice if they want the topic to be public to all members or private to moderators and keymasters. As you can see with the code above, that excludes the custom private topics from search results. Now what I need to do is update the pagination counts.

    For example, there’s a topic named “Testing” and another topic named “test123”. Pagination will show 2 topics. If “testing” is now marked private, pagination will show 2 topics. I need to figure out a way to update the pagination so it only shows 1 topic since that’s all is showing to participants. However if a moderator comes along with the required permission to view a private topic, the pagination should still show 2 topics since the moderator has permission to see the private topic.

    I hope this helps explain my goal.

    Thanks.


    Alex Stine
    Participant

    @alexstine

    Hello,

    Any ideas on this one? I really have no ideas here.

    Thanks.


    Alex Stine
    Participant

    @alexstine

    Hello,

    Any ideas? Maybe something like this?

    <?php echo bbp_get_forum_id(bbp_get_topic_id()); ?>

    Thanks.


    Alex Stine
    Participant

    @alexstine

    Okay, thanks for the info. If anyone is interested in trying to create a solution, I’d appreciate it. For now, I’ll keep on with the research.

    Thanks.

    In reply to: Display Topic Status

    Alex Stine
    Participant

    @alexstine

    Thanks, posted there. We’ll see if a response comes.


    Alex Stine
    Participant

    @alexstine

    Sorry about that, looks like I posted it in the wrong forum. Feel free to close or delete.Sorry LOL! LooksSorry

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