Add or Remove Columns in All Appointments Table

I've included the [app_all_appointments] shortcodes into my site, but I would like to remove some columns and add some extra data.

Is this possible?

  • Vaughan
    • Support/SLS MockingJay

    Hi @dan,

    You would need to custom code this yourself in the plugin, but you would lose the changes everytime you updated the plugin.

    The file with all the shortcode data is located here. "/appointments/includes/class_app_shortcodes.php"

    you need to find which shortcode you want to edit, then you can adjust the code there.

    Search for the class App_Shortcode_AllAppointments section, and then look at the process function.

    Adding new data might be the trickiest part though.

    Hope this helps

  • Dan
    • Flash Drive

    Is it ok to use the following code:

    $results = $wpdb->get_results( "SELECT * FROM " . $appointments->app_table . " WHERE status='confirmed' ORDER BY start " );

    I think I can make this work for my site, but I was wondering if there are potential performance or security problems.

  • Vladislav
    • Dead Eye Dev


    Yes, this bit of code will work - it will, however, disregard the appointments with "paid" status. If you want to include those too (which would make sense in a paid environment), you might want to do something along the lines of: WHERE status IN ('confirmed', 'paid') in your SQL. Also, this request doesn't consider paging, so if you have many appointments it can potentially return a large number of data - to be fair, that shouldn't really be a problem for confirmed/paid appointments unless you have a *really* large number of active appointments at any time on your site.

    • Vladislav
      • Dead Eye Dev

      Also (sorry for the double-post), the all appointments shortcode exposes the "app_all_appointments_after_table" filter, which passes up the whole markup for filtering. The optional second argument for the filter will have the actual results from the shortcode, so you don't actually have to do the database call yourself. Using this filter, you can either try removing the columns you don't want (you'll have to use preg_match/preg_replace for this unfortunately, as the passed-in markup is already formed as string) or alternatively, rebuild the resulting markup yourself, if you prefer this approach.

  • Dan
    • Flash Drive

    Thanks Vladislav, I've used your latest suggestion and used the 'app_all_appointments_after_table' filter within my functions.php to modify the shortcode output.

    Here is the code I used:

    add_filter('app_all_appointments_after_table','custom_appointments_columns', 10, 2);
    function custom_appointments_columns( $ret, $results ) {
    	global $appointments;
    	$ret  = '';
    	$ret .= '<div class="appointments-all-appointments">';
    	$ret .= '<table class="all-appointments tablesorter"><thead>';
    	$ret .= '<th class="all-appointments-service">'. __('Service', 'appointments' )
    		. '</th><th class="all-appointments-client">' . __('Client', 'appointments' )
    		. '</th><th class="all-appointments-date">' . __('Date/time', 'appointments' )
    		. '</th><th class="all-appointments-status">' . __('Status', 'appointments' ) . '</th>';
    	$colspan = 4;
    	$ret .= '</thead><tbody>';
    	if ( $results ) {
    		foreach ( $results as $r ) {
    			$ret .= '<tr><td>';
    			$ret .= $appointments->get_service_name( $r->service ) . '</td>';
    			$ret .= '<td>';
    			$ret .= $appointments->get_client_name( $r->ID ) . '</td>';
    			$ret .= '<td>';
    			$ret .= date_i18n( $appointments->datetime_format, strtotime( $r->start ) ) . '</td>';
    			$ret .= '<td>';
    			$ret .= App_Template::get_status_name($r->status);
    			$ret .= '</td>';
    			$ret .= '</tr>';
    		$ret .= '<tr><td colspan="'.$colspan.'">'. __('No appointments','appointments'). '</td></tr>';
    	$ret .= '</tbody></table>';
    	$ret .= '</div>';
    	return $ret;

    Is this what you were thinking? I removed the Provider Column.

  • Vladislav
    • Dead Eye Dev


    Since the argument passed to the filter is an already generated markup, I think this approach should work just fine. While you could have also tried removing the bits you don't need with something like preg_replace calls, I do agree that it would be an absolute pain to get just right. The approach you have taken should work just fine, and will also allow you to further customize the markup, as you need it.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.