fix: return JSON response for user group subscription AJAX saves#874
Merged
fix: return JSON response for user group subscription AJAX saves#874
Conversation
The AJAX handler for user group subscriptions was falling through to wp_die() without returning a proper JSON response, causing the UI to receive an empty response when users toggled user group checkboxes in the Notifications metabox. This prevented proper feedback and meant changes wouldn't persist until the post was saved manually. The fix ensures user group AJAX saves return wp_send_json_success() with the same structure as user subscriptions (empty arrays for no_access and no_email, since user groups don't have individual warning badges). Comprehensive integration tests verify both user and user group AJAX saves return valid JSON responses, handle authentication correctly, and persist subscriptions as expected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
When clicking on User Groups checkboxes in the Notifications metabox to subscribe/unsubscribe user groups from post notifications, the AJAX request would return an empty response. This caused:
The Users AJAX handler correctly returned
wp_send_json_success(), but the User Groups path fell through towp_die()without any response.Solution
Added
wp_send_json_success()response for User Groups AJAX saves, matching the behavior of User subscriptions:Test plan
NotificationsAjaxTest.php) covering:🤖 Generated with Claude Code