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

Add docs about action hooks when someone do the RSVP #787

Open
1 task done
oscarhugopaz opened this issue Aug 14, 2024 · 4 comments
Open
1 task done

Add docs about action hooks when someone do the RSVP #787

oscarhugopaz opened this issue Aug 14, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers

Comments

@oscarhugopaz
Copy link

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

  • I agree to follow this project's Code of Conduct
@oscarhugopaz oscarhugopaz added the enhancement New feature or request label Aug 14, 2024
@carstingaxion
Copy link
Collaborator

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!

@carstingaxion carstingaxion added the good first issue Good for newcomers label Aug 15, 2024
@carstingaxion
Copy link
Collaborator

carstingaxion commented Aug 29, 2024

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.

image

<?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!

@carstingaxion carstingaxion changed the title Add action hook when someone do the RSVP Add docs about action hooks when someone do the RSVP Aug 30, 2024
@carstingaxion carstingaxion added the documentation Improvements or additions to documentation label Aug 30, 2024
@carstingaxion
Copy link
Collaborator

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 /docs/developer/… with at least some examples from the 228 hooks available.

@carstingaxion
Copy link
Collaborator

carstingaxion commented Sep 8, 2024

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 developer/docs/ about the available RSVP hooks has its example code as part of gatherpress-awesome. So over time the template repo could become the library of working examples of how to extend Gatherpress.

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?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants