-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add docs about action hooks when someone do the RSVP #787
Comments
Hello @oscarhugopaz & thanks for your idea! This seems to make total sense to me. Don't hesitate to add additional ideas, it's super useful to get real-world feedback like yours! |
Hello again @oscarhugopaz, today I realized, that your wish is already fulfilled! 🎉 Since version 0.30.0 (#692) GatherPress' RSVPs are just comments, so you have the full set of 226 comment-related hooks available. I tested it successfully with an Email, that gets send, but for sure you could send that data to a CRM on the same way. <?php
/*
Plugin Name: GatherPress RSVP Action
Description: Sends an email, whenever someone sends an RSVP
Version: 0.0.1
Author: Carsten Bach
*/
/**
* Fires immediately after a comment is inserted into the database.
*
* @see https://developer.wordpress.org/reference/hooks/wp_insert_comment/
*
* @param int $id The comment ID.
* @param \WP_Comment $comment Comment object.
*/
function gatherpress_rsvp_on_wp_insert_comment_787( int $id, \WP_Comment $comment ): void {
if ( 'gatherpress_rsvp' !== $comment->comment_type ) {
return;
}
$mail = get_option( 'admin_email' );
$attendee = get_userdata( $comment->user_id );
$subject = sprintf(
'New RSVP by: %s',
$attendee->display_name
);
$event_title = get_the_title( $comment->comment_post_ID );
$message = sprintf(
'%s sent an RSVP for %s.',
$attendee->display_name,
$event_title
);
wp_mail( $mail, $subject, $message );
}
add_action( 'wp_insert_comment', 'gatherpress_rsvp_on_wp_insert_comment_787', 10, 2 ); https://gist.github.com/carstingaxion/3426a677aa426eb24922dac98178d296 But for sure, the GatherPress team could provide better documentation on this! |
Changed the title and added the Documentation label, because I’d like to keep this open as a reminder (and invitation to everybody) to update |
Just thinking … Often when reading tutorials, the used example code is provided in an accompanying repo. This kind of best-practice could make sense within a documentation as well. Imagine the piece of While an example like the above described email should not be enabled by default in gatherpress-awesome, it should be already in place, just hidden by a commented-out line of code (or something similar trivial). (What’s your opinion on this idea @mauteri?) |
Is your enhancement related to a problem? Please describe.
I use GatherPress as a meetup organizer, and would like to have and action hook when someone do the RSVP so it would be possible to send the data to other plugins, like FluentCRM, on RSVP
Designs
No response
Describe alternatives you've considered
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: