Skip to content

Campus Connect: admin notice and audit log on Approved For Pre-Planning (issue #1714 point 5)#1731

Open
dorsvenabili wants to merge 4 commits into
productionfrom
feature/1714-point5-cc-approval-notice
Open

Campus Connect: admin notice and audit log on Approved For Pre-Planning (issue #1714 point 5)#1731
dorsvenabili wants to merge 4 commits into
productionfrom
feature/1714-point5-cc-approval-notice

Conversation

@dorsvenabili
Copy link
Copy Markdown
Collaborator

Summary

Implements point 5 of #1714: when a Campus Connect application is approved for pre-planning, show a temporary success notice to the wrangler and write a permanent audit log entry.

Dependencies: requires #1728 (point 1, CC dropdown) and #1730 (point 4, email trigger) to be merged first. Point 4 introduces the wcpt_cc_approved_for_pre_planning action this PR hooks into.

Changes

wcpt-wordcamp/wordcamp-admin.php only (31 lines)

Constructor: registers handle_cc_approved_for_pre_planning() on the wcpt_cc_approved_for_pre_planning action.

New method handle_cc_approved_for_pre_planning( WP_Post $post ):

  1. Writes a _note post meta entry — same format used by the manual "Add Private Note" metabox — with:
    • timestamp: current Unix time (auto-rendered as a readable date in the log UI)
    • user_id: current user
    • message: "Application approved for pre-planning. Organizer notification email queued."
  2. Adds notice key 5 to $this->active_admin_notices, which the existing add_admin_notices_to_redirect_url / print_admin_notices pipeline picks up and displays after the save redirect.

get_admin_notices(): adds entry for key 5 — a green (updated) banner reading: "This Campus Connect application has been approved for pre-planning. An organizer notification email has been queued and a note has been added to the log."

The notice is shown once (after the redirect that follows saving). The log note is permanent.

Note on wcpt_add_private_note(): that helper is introduced in #1729 (point 3). This PR uses add_post_meta() directly with the same _note format to avoid a cross-PR dependency. Once #1729 is merged the direct call can optionally be replaced.

Test plan

  • Transition a CC post to wcpt-approved-pre-pl. After the save redirect, confirm a green success banner appears at the top of the post edit screen.
  • Confirm the banner text reads "This Campus Connect application has been approved for pre-planning. An organizer notification email has been queued and a note has been added to the log."
  • Confirm a new entry appears in the private notes log with the correct timestamp and the message "Application approved for pre-planning. Organizer notification email queued."
  • Reload the post edit screen. Confirm the green banner is gone (it is a one-time notice, not persistent).
  • Transition a non-CC post to any status. Confirm no notice and no note are added.
  • Transition a CC post to any status other than wcpt-approved-pre-pl. Confirm no notice and no note are added.

Generated with Claude Code

dorsvenabili and others added 2 commits May 21, 2026 16:22
#1714 point 4)

When a Campus Connect post transitions to wcpt-approved-pre-pl, fire a new
dedicated WordPress action wcpt_cc_approved_for_pre_planning. A separate action
is used (rather than reusing wcpt_approved_for_pre_planning) to avoid triggering
the non-CC hooks that listen on that action (add_organizer_to_central,
mark_date_added_to_planning_schedule), which are not appropriate for CC posts.

The wcor-mailer registers a matching trigger wcor_cc_approved_for_pre_planning
and callback so that an Automated Reminder post can be created in the admin to
send the approval email to the organizer (+ [email protected] via the
"organizing team" recipient) when this transition occurs.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…issue #1714 point 5)

When wcpt_cc_approved_for_pre_planning fires (i.e. a Campus Connect post
transitions to wcpt-approved-pre-pl), a new handler does two things:

1. Writes a permanent _note meta entry to the post log with a timestamp and
   the message "Application approved for pre-planning. Organizer notification
   email queued." — visible in the private notes log on the post edit screen.

2. Queues admin notice key 5, which the existing active_admin_notices /
   add_admin_notices_to_redirect_url / print_admin_notices pipeline displays
   as a green success banner on the next page load after the save redirect.

Depends on point 4 (PR #1730) for the wcpt_cc_approved_for_pre_planning action.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements the “Approved For Pre-Planning” follow-up for Campus Connect applications by surfacing immediate admin feedback to wranglers and recording a permanent entry in the application’s private log. The PR also wires a new Organizer Reminders trigger for the dedicated Campus Connect approval action.

Changes:

  • Add a wcpt_cc_approved_for_pre_planning handler that appends a _note log entry and queues a one-time admin notice after saving.
  • Add a new admin notice (key 5) confirming CC pre-planning approval + queued email + log entry.
  • Register a new Organizer Reminders trigger (wcor_cc_approved_for_pre_planning) mapped to the wcpt_cc_approved_for_pre_planning action.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-mailer.php Adds a new trigger definition and callback for the CC approval action.
public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php Fires a CC-specific approval action; logs a private note and queues an admin notice when that action runs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-mailer.php Outdated
Comment on lines +965 to +969
// Audit log note — same text as the admin notice, stored permanently with a timestamp.
add_post_meta(
$post->ID,
'_note',
array(
Comment on lines +78 to +82
'wcor_cc_approved_for_pre_planning' => array(
'name' => 'Campus Connect application approved for pre-planning',
'actions' => array(
array(
'name' => 'wcpt_cc_approved_for_pre_planning',
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI review requested due to automatic review settings May 21, 2026 14:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

Comment on lines +945 to +950
} elseif ( 'wcpt-approved-pre-pl' === $new_status
&& 'campusconnect' === get_post_meta( $post->ID, 'event_subtype', true ) ) {
// Fires when a Campus Connect application is approved for pre-planning.
// Uses a dedicated action to avoid triggering the non-CC hooks that listen
// to wcpt_approved_for_pre_planning (e.g. add_organizer_to_central).
do_action( 'wcpt_cc_approved_for_pre_planning', $post );
Comment on lines +976 to +978
// Queue the one-time admin notice that will display after the save redirect.
$this->active_admin_notices[] = 5;
}
array(
'timestamp' => time(),
'user_id' => get_current_user_id(),
'message' => __( 'Application approved for pre-planning. Organizer notification email queued.', 'wordcamporg' ),
* @param WP_Post $post The Campus Connect post that was approved.
*/
public function handle_cc_approved_for_pre_planning( WP_Post $post ) {
// Audit log note — same text as the admin notice, stored permanently with a timestamp.
Comment on lines +78 to +88
'wcor_cc_approved_for_pre_planning' => array(
'name' => 'Campus Connect application approved for pre-planning',
'actions' => array(
array(
'name' => 'wcpt_cc_approved_for_pre_planning',
'callback' => 'send_trigger_cc_approved_for_pre_planning',
'priority' => 10,
'parameters' => 1,
),
),
),
Copy link
Copy Markdown
Member

@dd32 dd32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-assisted review — generated with Claude Code and overseen by a maintainer. Please treat it as advisory and verify anything before acting on it.

Update: the merge-conflict resolution is the maintainers' to handle, not yours — annotated below.

Hi @dorsvenabili 👋 — reviewed as part of the #1714 set. What I did: fetched the branch, linted the changed PHP (clean on PHP 8.4), traced the action wiring, and test-merged against production and against #1730.

The mechanics are fine — it writes a _note, queues notice key 5 through the existing active_admin_noticesadd_admin_notices_to_redirect_urlprint_admin_notices pipeline, and using add_post_meta() directly (instead of #1729's wcpt_add_private_note() helper) to avoid a cross-PR dependency is a reasonable call.

Items

  1. [blocking] The stated dependency on #1730 is incorrect, and the two conflict. ℹ️ Conflict resolution is on the maintainers (handled at merge) — no action needed from you. Two things for the record: (a) this PR already contains its own do_action( 'wcpt_cc_approved_for_pre_planning', $post ), so it does not depend on #1730 for that action — the dependency note in the description is just out of date; (b) #1730 and #1731 conflict in wordcamp-admin.php and wcor-mailer.php (confirmed via git merge-tree), and the maintainers will keep both branches when merging.
  2. [semantic — needs a decision] The notice/note wording. This PR's banner and the permanent audit-log note fire on wcpt-approved-pre-pl and say "An organizer notification email has been queued." But #1730 moved the email trigger to Needs Orientation — so at the Approved-For-Pre-Planning transition, no email is queued. Once the team confirms which status sends the email (see #1730), the wording here needs to match. The maintainers will align this alongside the merge reconciliation.

Merge order

Needs #1728 underneath it (CC detection + reaching wcpt-approved-pre-pl). Does not actually need #1729. Reconciled with #1730 by maintainers at merge.

Per the Copilot review on this PR:
- The audit note and admin notice claimed the organizer email was "queued", but
  the reminders system sends synchronously (or not at all, if no reminder post is
  configured for the trigger). Reword to "triggered", which is accurate
  regardless of configuration or outcome.
- Fix the inline comment that claimed the note used the "same text as the admin
  notice"; the two strings are intentionally similar, not identical.

Note: there is no "wcor_cc_approved_for_pre_pl" docblock typo — the trigger ID is
spelled out in full (wcor_cc_approved_for_pre_planning) throughout. The
email-vs-status wording is left for the #1730/#1731 merge reconciliation (issue
#1714 points 4/5), pending the decision on which status sends the email.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@peiraisotta
Copy link
Copy Markdown
Collaborator

@dd32 thanks for the review!

I confirm that the banner should show up when the status changes to Needs Orientation, right after the organizer email is sent.

Please let me know if you need me to update anything in this PR or if this info is enough.

(@dorsvenabili)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants