Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify Community Team when new post is pending in Central #1058

Open
wants to merge 1 commit into
base: production
Choose a base branch
from

Conversation

timiwahalahti
Copy link
Collaborator

@timiwahalahti timiwahalahti commented Sep 21, 2023

Many WordCamp organisers do have a contributor role on the WordCamp Central website. That means they can write a post, but not publish it. When they are to publish that post, it goes to pending review status.

The team has witnessed a few times that the author doesn't know/understand that no one in Central is looking at pending posts automatically. That results in posts not being published (non at the moment) or delayed.

To avoid these situations, send notification to Community Team when the post status is changed to pending.

Fixes #718

Props @pkevan

Screenshots

CleanShot 2023-09-21 at 18 40 41@2x

How to test the changes in this Pull Request:

  1. Go to Central and create a new post
  2. Check "Pending review" on post sidebar
  3. Click "Send as pending"
  4. Check your mail (on local, mailcatcher)

After merge & deploy

  • Activate the plugin on Central

Copy link
Contributor

@pkevan pkevan left a comment

Choose a reason for hiding this comment

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

Thinking about this - I think it would be better to have this as an mu-plugin, restricting it's use on central via a site id check (or similar), rather than it being ambiguous as a plugin and potentially activated on other WordCamp (or Event) sites.

I'll leave some other feedback inline on the PR.

* @param WP_Post $post Post object.
*/
function send_notification_email( $new_status, $old_status, $post ) {
if ( 'pending' === $new_status && user_can( $post->post_author, 'edit_posts' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure of the purpose of the edit_posts check here - would that not be covered by edit privileges anyway?

wp_mail( 'support@wordcamp.org', $subject, $message );

// Save a pointer that notification has been sent.
update_post_meta( $post->ID, '_ncpp_sent', wp_date( 'Y-m-d H:i:s' ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need a method for clearing this on successful save, in case we switch between statuses such as:

draft => pending
pending => draft
draft => pending
pending => publish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🛑 Pending discussion
Development

Successfully merging this pull request may close these issues.

Notify Community Team when new post is pending in Central
3 participants