fix: prevent Edit Flow nonce checks from killing unrelated forms #883
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
Fixes #882
The notifications module was incorrectly checking the generic
_wpnoncefield against Edit Flow's expected action when posts were saved. This caused contact forms and other plugins that triggered post status transitions to fail, as Edit Flow would callwp_die()when their unrelated nonces didn't verify.Changes
save_post_subscriptions(): Now checks for Edit Flow's own form indicator (ef-save_followers) first, then verifies its own dedicated nonce field (ef_notifications_nonce) with actionsave_user_usergroups. Returns early instead of callingwp_die().handle_user_post_subscription(): Fixed faulty nonce logic that allowed requests without any nonce to pass through. Changed from! empty() && ! verify()to! isset() || ! verify().Walkthrough: How this fixes the reported issue
The Scenario
A user submits a speaker contact form on WordCamp. This form:
$_POST['_wpnonce']field for actionspeaker_submissiontransition_post_statushookBefore (The Bug)
What happened:
$_POST['_wpnonce']= nonce forspeaker_submissiontransition_post_statusfires →save_post_subscriptions()runs! empty( $_POST['_wpnonce'] )→ TRUE (the contact form set it)! wp_verify_nonce( $_POST['_wpnonce'], 'update-post_123' )→ TRUE (wrong action, verification fails)print_ajax_response()→wp_die()→ Request killedAfter (The Fix)
What happens now:
$_POST['_wpnonce']= nonce forspeaker_submissiontransition_post_statusfires →save_post_subscriptions()runs! isset( $_POST['ef-save_followers'] )→ TRUE (contact form didn't set this)Key changes
ef-save_followers) before doing anythingef_notifications_nonce) instead of the generic_wpnonceTest plan
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com