Forum Replies Created
-
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
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 inOtherwise it’s working as expected, also I fixed
if ($cur == $topic_id) {
toif ($cur_id == $topic_id) {
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.
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 happensTopic 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
In reply to: Enable comments under forums/topicsAnother save by Robin! Thank you so much, this worked like a charm
In reply to: Enable comments under forums/topicsGot the above from this stackoverflow thread
My problem is exactly like that except for bbpress
In reply to: Enable comments under forums/topicscomment_status
isclosed
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
In reply to: Enable comments under forums/topicsIt’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
In reply to: Enable comments under forums/topicsThe 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)
I want this to show on single-topic’s page
In reply to: Enable comments under forums/topicsFatal 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
In reply to: Show a list of forum moderatorsFor 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!In reply to: Get topics of subscribed to forums?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; ?>
In reply to: Get topics of subscribed to forums?@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 arrayI’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 onesIn reply to: Get topics of subscribed to forums?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 closerIn reply to: Get topics of subscribed to forums?@robin-w thank you for all the help, after a bit of tinkering I changed
bbp_get_user_forum_subscriptions
tobbp_get_user_topic_subscriptions
and it worked flawlessly, thank you so muchIn reply to: Get topics of subscribed to forums?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 activatedIn reply to: Get topics of subscribed to forums?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)) { ?>
In reply to: Get topics of subscribed to forums?Same error indicating this line
<?php if (in_array($forum_id, $subs)) { ?>
In reply to: Get topics of subscribed to forums?<?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; ?>
In reply to: Get topics of subscribed to forums?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?
In reply to: Get topics of subscribed to forums?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