Forum Replies Created
I’ve narrowed the problem down further and found a hack that works for me. If you look in buddypress-functions.php, there’s a function at line 739 called bp_legacy_theme_new_activity_comment. At line 770 is the process of inserting the new comment into the activity stream.
It begins by checking if $activities_template->activities is set. I’ve tested this function on an actual group page and found that this returns true, so it’s able to handle the activities effectively. However, on my custom template, this returns false; thus, the new comment data is never inserted. Of course this is separate from the process of saving the new comment to the database, so it makes sense that the comments still show up after refresh.
I’m still hoping to find a less hacky way to do this, because my current solution messes up other activity stream pages, but I’ve managed to get my custom template working by copying buddypress-functions.php into my theme folder and modifying line 768 to have a ‘groups’ scope.
So change line 768 from this:
bp_has_activities( 'display_comments=stream&hide_spam=false&include=' . $comment_id );
bp_has_activities( 'scope=groups&display_comments=stream&hide_spam=false&include=' . $comment_id );
Hope that helps! And if you’re able to find a better, less damaging way, please let me know. My hangup currently is that even if I manually set $bp->current_action to ‘groups’ in my template, it gets over-written at some point after page load, due to a url check that finds my template to not be at a group home url.
To customize your activity loop, I believe you’ll want to copy the ‘activity’ folder from ‘buddypress/bp-templates/bp-legacy/buddypress’ into the root folder of your theme. Then edit the activity-loop.php file within that new copy of the ‘activity’ folder.
I set up a clean WordPress/BuddyPress install with the same versions, and managed to narrow down the problem a bit. Outside of a BuddyPress group page, I cannot show status updates to the group by default, (as opposed to personal updates.) If I change the has_activities loop’s scope to ‘groups’, then the group posts show up, but the comment AJAX problem returns.
Is there a way I can get the validation that allows these posts to show up on the group’s page, and make it work in my custom template?
I found some custom code in my in-theme ‘activity’ folder and replaced it all with fresh files. The comments then worked! Until… I set ‘scope=groups’ in the has_activities loop. Now the problem is back. Can comments not be enabled while scope is set?
I’ve also noticed that there are no AJAX calls occurring to check for new activity, and I don’t know why that isn’t working either, but perhaps that sheds some light on the source of the problem? As with the comments, the AJAX calls are working appropriately outside of my custom template.