athep (@athep)

Forum Replies Created

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

  • athep
    Participant

    @athep

    I set $forum_id = bbp_get_forum_id() ;

    and change these two

    if (!empty ($prev_id) && wp_get_post_parent_id($prev_id) == $forum_id) {

    and

    if (!empty ($next_id) && wp_get_post_parent_id($next_id) == $forum_id) {

    Notice the equal sign, that solved the problem!

    Thank you so much Robin!

    EDIT:

    The last topic links in every forum somehow get left behind, only the last ones.. I’ll tinker around and post my findings


    athep
    Participant

    @athep

    Thank you Robin,

    I tried this, I was inserting this in single-topic.php so I was not sure which one would work.

    $topic_id = bbp_get_topic_id() ; works well, the only issue is that once it nears the end, the other forums start leaking in, if prev or next is empty they leak in

    Otherwise it’s working as expected, also I fixed if ($cur == $topic_id) { to if ($cur_id == $topic_id) {


    athep
    Participant

    @athep

    I think I got timed out, not sure if my reply was deleted.

    I haven’t solved it yet, I did find two promising threads though but I couldn’t make sense of it.


    athep
    Participant

    @athep

    I made the list

    
    <?php $args = array( 'post_type' => 'topic', 'post_parent' => bbp_get_forum_id() ); $loop = new WP_Query( $args ); ?>
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
     <a href="<?php echo get_the_permalink(); ?>"><?php the_title(); ?></a>
    <?php endwhile;?>
    

    This gives me all the topics under the current topic’s forum (I’m on single-topic.php)

    Is there a way I could limit the list to 5 links (that’s easy, post_per_page = 5) but on top of that only show the adjacent posts?

    
    Topic 3 link
    Topic 4 link
    Topic 5 link <----- I'm here
    Topic 6 link
    Topic 7 link
    

    In the above example, it’s showing me 2 previous adjacent posts and to next adjacent posts

    What happens is if I set post_per_page to 5 then this happens

    
    Topic 1 link
    Topic 2 link
    Topic 3 link 
    Topic 4 link
    Topic 5 link <----- I'm here
    

    The current link is always last, I realized this is more of a wordpress question but I’d like to try my luck here since I already opened a thread


    athep
    Participant

    @athep

    Another save by Robin! Thank you so much, this worked like a charm


    athep
    Participant

    @athep

    Got the above from this stackoverflow thread

    My problem is exactly like that except for bbpress


    athep
    Participant

    @athep

    comment_status is closed in these pages, wish I knew of a way to enable them.

    I got this from stackoverflow

    
    function set_post_comment_status( $post_id, $status = 'open' ){
        global $wpdb;
        $wpdb->update( $wpdb->prefix . 'posts', [ 'comment_status' => $status ], [ 'ID' => $post_id ] );
    }
    

    and tried passing the topic id, it didn’t work


    athep
    Participant

    @athep

    It’s my site’s current layout, I have the forum or topic (depending on which page I’m on) on top and hopefully if I get a solution, the wordpress comments under


    athep
    Participant

    @athep

    The plugin successfully activated once I moved to a live server, so that’s fine. But it’s not what I was looking for, am I missing something?

    I’d like wordpress comments under forums or topics (single-forum.php or single-topic.php)


    athep
    Participant

    @athep

    I want this to show on single-topic’s page


    athep
    Participant

    @athep

    Fatal error: Uncaught Error: Cannot use a scalar value as an array in ..\wp-content\plugins\bbpress-post-topics\index.php:924
    Stack trace: #0 ..\wp-includes\class-wp-hook.php(287): bbppt_activate('')
    #1 ..\wp-includes\class-wp-hook.php(311): WP_Hook->apply_filters('', Array)
    #2 ..\wp-includes\plugin.php(484): WP_Hook->do_action(Array)
    #3 ..\wp-admin\plugins.php(193): do_action('activate_bbpres...')
    #4 {main} thrown in ..\wp-content\plugins\bbpress-post-topics\index.php on line 924

    Edit: formatted for readability


    athep
    Participant

    @athep

    For anyone looking for a solution, it’s as simple as calling

          <?php
            echo '<pre>';
            print_r(bbp_get_moderators(bbp_get_forum_id()));
            echo '</pre>';
          ?>

    Or you could echo bbp_get_moderator_list(bbp_get_forum_id()); for a simple list of moderators. Remember to put it inside the loop!


    athep
    Participant

    @athep

    I finally got it to work clumsily

    <?php global $current_user; get_currentuserinfo(); $uid = bbp_get_current_user_id(); ?>
    <?php if ( bbp_get_user_forum_subscriptions( $uid ) ) : ?>
    	<?php while ( bbp_forums() ) : bbp_the_forum(); ?>
    		<?php $subs[] = bbp_get_forum_id(); ?>
    	<?php endwhile; ?>
    	<?php $forumid = implode(', ', $subs); ?>
    	<?php echo do_shortcode('[bbp-display-topic-index template ="short" forum="' . $forumid . '"]'); ?>
    <?php endif; ?>

    athep
    Participant

    @athep

    @robin-w I visited your website and noticed all the amazing work you’ve done, thank you.

    What I’ve been trying to do all along was to get your shortcode [bbp-display-topic-index show='5' forum ='10,11,12'] to php so that the forums could be the IDs of the forums the user is subscribed to.. so an array

    I’ve been trying to get it to work to no avail, [bbp-display-topic-index show='5' forum ='$forum_id'] or the likes return nill or with all the topics from all the forums, not just the subscribed ones


    athep
    Participant

    @athep

    Correction, I am getting the bbp_forum_title() that we passed but not <?php bbp_get_template_part( 'loop', 'single-topic' ); ?> that I was initially trying to filter.. No worries tho, one step closer


    athep
    Participant

    @athep

    @robin-w thank you for all the help, after a bit of tinkering I changed bbp_get_user_forum_subscriptions to bbp_get_user_topic_subscriptions and it worked flawlessly, thank you so much


    athep
    Participant

    @athep

    It’s still returning null, no output whatsoever. I even print_r($subs) inside the while loop and nothing shows up, I’m using the latest versions of bbpress and wordpress, the theme is a blank starter theme with only bbpress plugin activated


    athep
    Participant

    @athep

    I have included $subs = explode(',' , $subs); and it’s returning nothing, it has no error or any output..

    The other error was Warning: in_array() expects parameter 2 to be array, bool given in ..../content-main.php on line 21

    Line 21 is <?php if (in_array($forum_id, $subs)) { ?>


    athep
    Participant

    @athep

    Same error indicating this line <?php if (in_array($forum_id, $subs)) { ?>


    athep
    Participant

    @athep

    <?php global $current_user; get_currentuserinfo(); $uid = bbp_get_current_user_id(); ?>
    <?php if ( bbp_get_user_forum_subscriptions( $uid ) ) : ?>
    <?php $subs = bbp_get_user_forum_subscriptions( $uid ) ; ?>
      <?php while ( bbp_forums() ) : bbp_the_forum(); ?>
      <?php $forum_id = bbp_get_forum_id( $forum_id ); ?>
    	<?php if (in_array($forum_id, $subs)) { ?>
        <p><?php bbp_forum_title(); ?></p>
    	<?php } ?>
      <?php endwhile; ?>
    <?php endif; ?>

    athep
    Participant

    @athep

    There were a few syntax errors I fixed with your code, and the error message ends with the files location stating that the error comes from the line ‘<?php if (in_array($forum_id, $subs)) { ?>’

    Your second snippet returns null, nothing, maybe bbp_forum_title() won’t work in this context?


    athep
    Participant

    @athep

    Hello Robin, thank you for your reply. I got this error Warning: in_array() expects parameter 2 to be array, bool given in... I’d appreciate helping me figure it out if possible

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