Hey Mark,
Yes! This can be done. You will need to use the filter mentioned in that FAQ to add the field “registration_date” to the available registrant data:
function ru_attendee_list_settings_filter( $attendee_list_fields ) {
// adds custom field data to the $registrants_data for the custom attendee list
$attendee_list_fields = array( 'first_name', 'last_name', 'user_id', 'registration_date' );
return $attendee_list_fields;
}
add_filter( 'rtec_attendee_list_fields', 'ru_attendee_list_settings_filter', 10, 1 );
Then it will be available in the registrant data – $registrant[‘registration_date’]
Also, we intend to add some additional field types at some point but this forum post can help you add a dropdown select box which should help:
https://ww.wp.xz.cn/support/topic/add-field-type/
Let me know if you need more help!
– Craig
Thread Starter
mheffo
(@mheffo)
Hi Craig,
Thanks for the reply and the code help.
I was able to create a drop down select box which works much better then a comment box for this purpose. And I can now use a comment box for its intended purpose.
I’ve added in the code to add the registration_date field and tweaked the headings but when the page loads the date is always before the custom1 field. E.g.
Player | Attending? | Submission Date
first_name | custom1 | registration_date
appears as
Player | Attending? | Submission Date
First_name | registration_date | custom1
Is this because the registration_date field will always come before the custom fields due to the back end setup?
If so that’s ok.
Last question hopefully on this and I think I know the answer already, is it possible to use {custom1} or {custom2} fields within the email notification? I’ve tested and the fields just appear as is so I’m thinking it’s not possible.
Thanks,
Mark
Hey Mark,
For the field order question, any field order should be possible. Are you using the snippet that displays registrations in a table? That example just loops through all of the fields and outputs them but you can adjust the code to output in any order. I can give you an example if you’d like.
As for the templates in the notification email, it’s a little confusing but the templates for the custom fields map to the label of the field surrounded by brackets:
{Custom Label}
Does it work if you try those?
– Craig
Thread Starter
mheffo
(@mheffo)
Hi Craig,
Yeah if you have an example that would be great as I’m using the example that just loops through the fields etc. Thanks.
Sorry for the confusion re using custom fields in the email confirmation notification. I’m using the custom fields in the start of the email e.g.
Hey {first},
Thanks!
You have registered your reply for {event-title} at {venue} on {event-date}.
Your reply is: {custom1}
Comment: {custom2}
******
When the user receives the email no text appears for {custom1} or {custom2}. E.g.
Your reply is:
Comment:
It doesn’t appear the custom fields are pulling the text from the back end. Fyi all the other fields in the email are populated.
Thanks,
Mark
Hey Mark,
Do you have a link that you can send to an event that has a registration form? I can send you the templates to use then. It would just be the label of the field in brackets. So if your first custom field has the label “Attending?”, you would use this template:
{Attending?}
not {custom1}.
I can send you a working example of the attendee list code then too. I’m currently out of town so it may be Monday before I get back to you but I will try sooner!
Thanks,
Craig
Thread Starter
mheffo
(@mheffo)
Hi Craig,
Sorry after I read your reply I realised I should have clicked the Show Notes button of the Custom Field to view the Email template text. Doh! π
Email notification with custom fields is populating correcting now. Thanks.
Yeah that’s fine for the working example of the attendee list, enjoy your break.
Thanks,
Mark
Thank you for your patience!
Here is the example I came up with so you can see how to custom order the fields:
function ru_custom_attendee_list( $registrants_data ) {
$html = '<div class="tribe-events-event-meta rtec-event-meta rtec-attendee-list-meta">';
$html .= '<h3 class="rtec-section-title">Currently Registered</h3>';
$html .= '<div style="padding: 0 4%">';
$html .= '<table>';
$html .= '<thead>';
$html .= '<tr>';
$html .= '<th>Location</th>';
$html .= '<th>First</th>';
$html .= '<th>Last</th>';
$html .= '<th>Profession</th>';
$html .= '</tr>';
$html .= '</thead>';
$html .= '<tbody>';
// loops through the $registrants_data and displays the values in their array order
foreach ( $registrants_data as $registration ) {
$html .= '<tr>';
$html .= '<td>' . esc_html( $registration['custom1'] ) . '</td>';
$html .= '<td>' . esc_html( $registration['first_name'] ) . '</td>';
$html .= '<td>' . esc_html( $registration['last_name'] ) . '</td>';
$html .= '<td>' . esc_html( $registration['custom2'] ) . '</td>';
$html .= '</tr>';
}
$html .= '</tbody>';
$html .= '</table>';
$html .= '</div>';
$html .= '</div>';
echo $html;
}
// removes the default attendee list, otherwise you will have two lists
remove_action( 'rtec_the_attendee_list', 'rtec_the_default_attendee_list' );
add_action( 'rtec_the_attendee_list', 'ru_custom_attendee_list' );
function ru_attendee_list_settings_filter( $attendee_list_fields ) {
// adds custom field data to the $registrants_data for the custom attendee list
$attendee_list_fields = array( 'first_name', 'last_name', 'custom1', 'custom2' );
return $attendee_list_fields;
}
add_filter( 'rtec_attendee_list_fields', 'ru_attendee_list_settings_filter', 10, 1 );
Hopefully it helps!
Thread Starter
mheffo
(@mheffo)
Thanks for the code Craig. Works a charm.