• Resolved simon_beanstalk

    (@simon_beanstalk)


    Hey! I really like your plugin :).

    A site I’ve built hosts event information for site members and use your plugin to allow people to RSVP. I’m looking to collect additional data from members; how many adults and children they’re bringing along, as well as comments.

    I’ve modified /[THEME]/tribe-events/rsvp-form.php to include the following in the appropriate spots:

    <label for="eventrocket_adults">Adults:</label>
    <input type="text" name="eventrocket_adults" id="eventrocket_adults" value="" placeholder="<?php esc_attr_e( '0', 'eventrocket' ) ?>" />
    <label for="eventrocket_children">Children:</label>
    <input type="text" name="eventrocket_children" id="eventrocket_children" value="" placeholder="<?php esc_attr_e( '0', 'eventrocket' ) ?>" />
    <label for="eventrocket_comments">Comments:</label>
    <textarea name="eventrocket_comments" id="eventrocket_comments" value="" placeholder="<?php esc_attr_e( 'Please let us know about who you're bringing with you - Name, Age, etc', 'eventrocket' ) ?>"></textarea>

    But I’m at a loss for how to hook it in and collect the data in the back-end. :(.

    I’ve seen the other similar threads: (https://www.ads-software.com/support/topic/rsvp-fields?replies=10#post-7360355 and https://www.ads-software.com/support/topic/collect-additional-information?replies=10), but they seem to only cater for anonymous users… I can’t seem to find an action that deals with logged in user’s submissions!

    Thanks in advance for any help you can offer!

    https://www.ads-software.com/plugins/event-rocket/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Barry

    (@barryhughes-1)

    Hi Simon,

    Glad you like it!

    Firstly I’d note that yours is the latest in a line of customization requests that make me think a) we need more hooks in here to facilitate this sort of thing and b) we need to document it somewhere! So, once I have time, I’ll try to make those things happen.

    For the time being though in the case of authenticated users you would probably need something like this:

    add_action( 'wp', 'add_custom_rsvp_data' );
    
    function add_custom_rsvp_data() {
    	// The following two lines simply borrow logic from EventRocket_RSVPForm
    	if ( ! isset( $_POST['rsvp_attend'] ) && ! isset( $_POST['rsvp_withdraw'] ) ) return;
    	if ( ! wp_verify_nonce( $_POST['eventrocket_rsvp_check'], 'mark_attendance' . get_current_user_id() . get_the_ID() ) ) return;
    
    	// Test to see if the information you are interested in was posted
    	if ( empty( $_POST['some_info'] ) ) return;
    
    	// Stay safe and validate it appropriately - the following is not going to be a suitable approach in all cases
    	$some_info = filter_var( $_POST['some_info'], FILTER_SANITIZE_SPECIAL_CHARS );
    
    	// Save it using a naming scheme that will let you easily test for
    	// its existence and retrieve it later
    	update_user_meta( get_current_user_id(), '_RSVP_Field_Extra_Field_A', $some_info );
    }

    The above is completely untested and will need a lot of adjustment – but it should illustrate the basic process ??

    Thread Starter simon_beanstalk

    (@simon_beanstalk)

    Thanks Barry!

    I ended up using update_user_meta a little differently to how you suggested, so that the meta key included the post ID (otherwise different values in each event would overwrite each other).

    $post_id = get_the_ID();
    $name_eventrocket_adults = 'eventrocket_adults'.$post_id;
    update_user_meta( get_current_user_id(), $name_eventrocket_adults, $eventrocket_adults );

    There’s probably a better, less bloat-y way to do this, but I’m not going to chase it.

    Thanks again! Sorry to see you won’t be supporting this plugin any more :(. All the best with your future endeavours!

    Plugin Author Barry

    (@barryhughes-1)

    Looks good!

    Yep there might be some super efficient way to do it but then again if it works and is easy to read, that’s important too ??

    Thanks again! Sorry to see you won’t be supporting this plugin any more :(. All the best with your future endeavours!

    Thank you!

    If time was in more plentiful supply things might be different. Even so, the plugin itself should continue to work and the code is also available on GitHub (besides WP SVN) should anyone want to fork it/take pieces and re-work them etc.

    Good luck with the project ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Collecting additional data in RSVP's for LOGGED IN members’ is closed to new replies.