Open tw2113 opened 10 years ago
Not sure how related it will be, but we have a couple add_action()
calls to user_deserves_achievement
but user_deserves_achievement
is a filter, and there is no do_action()
for it.
Changing them to add_filter()
hasn't helped solve the trigger issue though.
confirming that this is not fixed with the step fixes found in BOS1.3.5. Issue still persists.
Related #10 7 months ago has issues with joining specific group.
Possible but not tested yet: order of operation. Not sure if groups_join_group, which is running first, is preventing ever getting to groups_join_specific_group.
Experiencing similar effect to #10 of log showing triggered for named user but no badge award
So, tonight I grew tired that this issue existed, I wanted this issue done and figured out.
I think I have it figured out.
The issue, as far as I can tell, stems from this line in badgeos_bp_trigger_event():
$this_trigger = current_filter();
full file: https://github.com/opencredit/BadgeOS-Community-Add-on/blob/master/includes…
This is where the problem starts. BuddyPress has a filter hook named "groups_join_group". It does NOT have a "groups_join_specific_group". Trust me, I did a grep on the svn repo for the entire history of BuddyPress to check.
So, current_filter() is never going to return "groups_join_specific_group", but it will return "groups_join_group". This is great for when we're wanting to award for joining any group, but it's going to fail each time when we need to award for a specific group because it's never going to match "groups_join_specific_group" in the meta value for "_badgeos_community_trigger".
I tested this theory by hardcoding $this_trigger to 'groups_join_specific_group" and it went through like expected. It awarded me the achievement.
So the question is how do we resolve this? Is there a way we could check the current group somehow at the point of "groups_join_group" and patch it in at that point?
See: 669a98483b084822706109e3a343c4ee8ab617ca and 698a99b9953df5108f3e39c855fba9be5a1e7f94.
Essentially I added a custom action hook to groups_join_group and do a groups_join_specific_group action hook. With that, I pass in an array of group_id and user ID to our trigger callback. It doesn't appear that those are necessarily needed, but I believe it's better to pass them in anyway, just in case we need them in the future. Next, I pass in all of the available parameters to badgeos_bp_trigger_event()'s foreach at the end, so that it can properly grab the triggered trigger and other parameters and proceed through the rest properly.
I have tested it within my limited setup, and it's working for me thus far. However, I'd love to have others test it out as well. I can point you to the right zip to download the fixed branch from, if anyone needs it.
Possibly not adding activity stream notification still.
Set to be a part of a 1.2.1 release. We can deal with new information at that point.
Need to reopen. It was not tested with requests that need to be approved to join, which was a detail that slipped my mind at the time..
Pushed up new changes and have requested someone from the forums help test the newest changes. Will hopefully now cover both private and hidden groups.
Positive feedback on forum for newest updates.
Gonna re-close and release today.
Hey Michael:
I'm still having an issue with the join a group not triggering.
I have a badge set to trigger when anyone joins a group of any kind, not a specific group. But it doesn't trigger when people join a group.
These are private groups. After reading this thread I tried turning one of the groups to public, and that fixed it. So it seems to be the request membership issue you mentioned above. But again, this isn't for the specific group trigger, just the regular one.
My badgeos & community add on plugins are up to date.
Thanks!
Obligatory re-open.
So to summarize...private group + "join any group" trigger?
Correct.
Could this be because private groups are covered by a separate action: groups_group_request_managed in groups_screen_group_admin_requests in the file buddypress/bp-groups/bp-groups-screens.php?
I experimented by adding the following lines in the community addon: In badgeos_bp_load_community_triggers I added
`add_action( 'groups_group_request_managed', 'badgeos_bp_trigger_event', 10, 10 );`
right after the loop loading all triggers.
In badgeos_bp_trigger_event I added the line:
if ($this_trigger=='groups_group_request_managed') {$this_trigger='groups_join_group';}
immediately after these lines:
// Grab the current trigger
$this_trigger = current_filter();
This is not the best way to do it, but seems to confirm that the action hook required is groups_group_request_managed. I renamed the trigger just for testing because otherwise it doesn't add to the trigger count for joinin a group
I have this much already: https://github.com/opencredit/BadgeOS-Community-Add-on/blob/master/includes/rules-engine.php#L156:L182
I just need to expand on it more including some testing of it all.
If I'm reading things properly, groups_join_group is only for public groups, and doesn't fire for private/hidden. Hook name -> params groups_membership_accepted -> user id, group id, accepted status (bool) groups_accept_invite -> user id, group id
Need to find a way to pass arguments from those two hooks into functionality that would verify award.
This is starting to feel less like a bug, and more like missing enhancements, for issue clarification at present time. Vague description of the step type very possible
I can't get achievements to award when they're set to be for specific groups. The
badgeos_bp_user_deserves_group_step()
function never seems to get reached, nor thegroups_join_specific_group
step. We do reachgroups_join_group
It'll be considerate for us to try and fix this soon, as we have users trying to rely on this. http://wordpress.org/support/topic/badgeos-trigger-not-working?replies=17