Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-sales domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the better-click-to-tweet domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-amazon domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-stats domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114 How to add phone number column to event registrations admin area | Event Espresso - Staging Server
and it worked! But now I want to add a column for the phone number, how do I do that? do I just copy and paste the same function that I used: <?php
/*
Plugin Name: Site plugin for islandartparty.com
Description: Site specific code for islandartparty.com
*/
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */
function tw_custom_columns( $columns, $screen ) {
// This is for the 'default' registration list table
// Event Espresso -> Registrations.
if($screen == 'espresso_registrations_default'){
// EEH_Array::insert_into_array() allows you to specific a specific key
// that you want to add your additional column before/after.
// This adds the custom-reg-qst-column just before 'actions' column.
$columns = EEH_Array::insert_into_array(
$columns,
array( 'custom-reg-qst-column' => 'Custom Reg Question' ),
'actions'
);
}
//Add a custom-reg-qst-column column to the contact list table.
if($screen == 'espresso_registrations_event_registrations') {
//This is another method you can use that just adds the column to the end of the array.
$columns['custom-reg-qst-column'] = 'Admin Notes';
}
return $columns;
}
add_filter('FHEE_manage_event-espresso_page_espresso_registrations_columns', 'tw_custom_columns', 10, 2);
function tw_checkin_table_custom_question( $item, $screen ){
//Sanity check to confirm we have an EE_Registration object.
if($item instanceof EE_Registration){
//Pull the answer object for Question ID 11 using the current registration.
$question_id = 11;
$answer_obj = EEM_Answer::instance()->get_registration_question_answer_object( $item, $question_id );
if ( $answer_obj instanceof EE_Answer ){
//If we have an answer object, echo the 'pretty' value for it.
echo $answer_obj->pretty_value();
}
}
}
// 'custom-reg-qst-column' in the action name here needs to be changed to match your column name set in the function above.
add_action( 'AHEE__EE_Admin_List_Table__column_custom-reg-qst-column__event-espresso_page_espresso_registrations', 'tw_checkin_table_custom_question', 10, 2 );
//Enable sorting for the custom column.
function tw_ee_sortable_columns( $sortable_columns, $screen ) {
if ( $screen == 'espresso_registrations_default' ) {
$sortable_columns['custom-reg-qst-column'] = array('custom-reg-qst-column' => false);
}
return $sortable_columns;
}
add_filter('FHEE_manage_event-espresso_page_espresso_registrations_sortable_columns', 'tw_ee_sortable_columns', 10, 2);
// The models only accept certain values for orderby, normally the column name is used but if thats custom we'll need to pass a value
// the models understand. THis sets the order by to 'Answer.ANS_value' when you select the custom column above.
function tw_ee_get_orderby_for_registrations_query( $order_by, $request)
{
if( isset($order_by['custom-reg-qst-column'] ) ) {
$fixed_order_by = array(
'Answer.ANS_value' => $order_by['custom-reg-qst-column']
);
unset($order_by['custom-reg-qst-column']);
foreach( $order_by as $key => $value) {
$fixed_order_by[$key] = $value;
}
return $fixed_order_by;
}
//Return the original order_by array.
return $order_by;
}
add_filter('FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query', 'tw_ee_get_orderby_for_registrations_query', 10, 2);
/* Stop Adding Functions */
or do I add certain aspects of this code into what’s already there? I hope that makes sense.
So either duplicate the entire function above so there are two but then it’s pulling the phone number instead. OR are there code snippets I could add so I don’t have to duplicate it?
You definetly do not want to duplicate a PHP function. If you were to do that, it would bring the site down because PHP does not allow a function to be declared more than once.
Here’s a readymade snippet that adds the phone number as a custom column:
The support post ‘How to add phone number column to event registrations admin area’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.