[Resolved] Activity comments post blank until refresh
-
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.
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 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 also have the same problem.
Occurs in hidden group and private group.I also hope to resolve this problem.
Hi @soran7
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[0] 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 );
to this:
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.
You are a genius!!
I was successful in my template!I am very happy problem that was suffering for a long time has been resolved.
Thank you very much.Awesome, glad it’s working for you!
- The topic ‘[Resolved] Activity comments post blank until refresh’ is closed to new replies.
Tbarnes37
@tbarnes37
10 years, 6 months ago
WP 3.9.1
BP 2.0.1
website: localhost dev site using MAMP
Scenario
I am building a member home page that includes a group activity stream to provide a group “wall” sort of experience. To do this, I made a copy of the ‘activity’ folder from bp-templates/bp-legacy/buddypress and placed it in my theme folder. Then in my member homepage template, I included an activity stream by adding:
<?php locate_template( array( 'activity/index.php' ), true, false ); ?>
The Problem
Everything on the activity feed works, including adding, favoriting, and deleting status updates, but when a member comments on a status update, the comment is added, animation and all, but with no content – just ‘replied’ and the ‘Reply’ button, as shown here:
https://www.dropbox.com/s/0yh2e1b5f2fw7zk/problem.png
However, after a manual refresh, the comment is there with all its content, working perfectly.
Other Threads
I have found several others posting with similar problems, but no solutions that have worked for me:
What I’ve Tried
I’ve tried disabling all other plugins and removing all custom functions from my theme, and there was no change. I can’t try it in a different theme, since the problem IS my theme. The problem only occurs in my custom template. When I go to the group’s page, or to a member’s page, commenting works perfectly.
Thanks for reading!