Plugin Author
Barry
(@barryhughes-1)
Hi Matthew,
So the remaining issue is one of displaying the collected information?
Event Rocket itself leverages the tribe_events_cost_table hook to add it’s own admin UI (this happens on priority 5) so it would probably work for you to do the same, on a priority of 6 perhaps:
add_action( 'tribe_events_cost_table', 'my_rsvp_ui', 6 );
function my_rsvp_ui() {
echo 'Display collected information';
}
I could certainly look at improving the customizability of this area if you’d like to log an issue over on GitHub 🙂
Plugin Author
Barry
(@barryhughes-1)
… Or indeed you could strip out the default UI with a remove_action() call and redo it with something custom. On that level, there’s really nothing you cannot change.
Hey Barry,
Thank you! I just needed a point in the right direction. I think this should work out. I’ll let you know otherwise!
Matt
Hey Barry,
Thanks! You’ve been very helpful. So I have also been following this topic here: https://ww.wp.xz.cn/support/topic/rsvp-fields?replies=4
I can’t seem to get my meta data to ever be created. I have my form field set up within the rsvp-form.php form. It has a unique name/id of “rvsp_additional_attendees”. Also see below for the code that should be capturing this.
add_filter( 'eventrocket_rsvp_accept_anon_submission', 'rsvp_store_additional_data', 20 );
function rsvp_store_additional_data() {
$event_id = get_the_ID();
$anon_user = get_current_user_id();
if( ! add_post_meta( $event_id, "_RSVP_Field_{$anon_user}_Additional_Attendees", $_POST['rvsp_additional_attendees'], true))
{
update_post_meta( $event_id, "_RSVP_Field_{$anon_user}_Additional_Attendees", $_POST['rvsp_additional_attendees'] );
}
}
I’m expecting that after I hit submit on my form:
<button class="eventrocket attendees" name="additional_attendees" value="__anon" type="submit">
<?php _ex( 'Update Additional Attendees List', 'anon attendance button', 'eventrocket' ) ?>
</button>
That the meta data field would be created in the postmeta table. But it isn’t. I’ve checked the headers and verified that the form data is in fact being passed through properly.
Any ideas on what I’m doing wrong?
Thanks!
Hey Barry nevermind! I solved my own problem. After reviewing the source code more, I modified my filter to use this:
add_filter( 'tribe_events_single_event_after_the_meta', 'rsvp_store_additional_data', 20 );
Data is now being saved. Not sure if that’s what it needs to be, but it works.
Thanks for all your help!
Plugin Author
Barry
(@barryhughes-1)
Hi Matthew,
Your own code diverged a little from what I suggested here – and I imagine the reason it didn’t work (before you changed the hook) was that you are not returning anything from your rsvp_store_additional_data() function.
By contrast, if you look at what I outlined in the other topic you can see that the rsvp_maybe_store_additional_data() function receives and returns a variable called $accepted – this is very important.
It is also worth highlighting that Event Rocket performs some basic security and sanity checks and $accepted will only be true when those are satisfied.
So, your modified version where you use the tribe_events_single_event_after_the_meta hook probably will indeed work – but it arguably is not “safe”.
How much of a real world concern that is is something I’d need to leave you to assess, but sticking to the form outlined in the other post is what I’d recommend.
Thanks for telling me that, I wasn’t aware of that intent of that function call. I’ll make those adjustments. Again, thanks for all your help! Love your plugin.
Plugin Author
Barry
(@barryhughes-1)
Happy to help — and thank you!