"Created by" column in Appointment list in Admin

I’d like to have a column named “Created by” next to “Created on” column in the admin appointment list so if any one creates any Appointment from the admin it is mentioned there.

  • Nithin
    • Support Wizard

    Hi John Neilson,

    Hope you are doing good today. :slight_smile:

    I don’t see a quick workaround regarding this, I’m checking this with our Second Level Support(SLS) team, to see whether they is any hooks that could be worked upon to make this work. Please do note that if it’s something which our SLS team finds to be too complex, or require a lot of custom changes, then it’ll fall under custom development.

    Will keep you posted once I get further feedback regarding this. Have a nice day ahead. :slight_smile:

    Kind Regards,

    Nithin

  • Panos
    • SLS

    Hi John Neilson ,

    You can try adding the following snippet in a mu-plugin :

    add_filter( 'appointments_my_appointments_list_columns', function( $cols ){
    $col['created-by'] = 'Created by';
    array_splice( $cols, 7, 0, $col );
    return $cols;
    } );

    add_action( 'appointments_my_appointments_list_row', function( $app, $key, $value ){

    if ( 'created-by' != $key ) {
    return;
    }

    $created_by = appointments_get_appointment_meta( $app->ID, 'created-by' );
    $created_by_user = ( ! $created_by || empty( $created_by ) ) ? '' : get_user_by( 'ID', (int) $created_by );
    $user = ( ! $created_by_user instanceof WP_User ) ? '' : $created_by_user->display_name;
    ?>
    <td class="column-<?php echo $key; ?>">
    <?php echo $user; ?>
    </td>
    <?php

    }, 20, 3 );

    add_action('app-appointment-inline_edit-after_save' , function( $app_id, $data ){

    // Lets ignore the updates and insert meta only on new appointments
    if ( 0 != $_REQUEST[ 'app_id' ] ) {
    return;
    }

    appointments_update_appointment_meta( $app_id, 'created-by', get_current_user_id() );

    }, 20, 2 );

    This should be adding a new column, after the “Created on” column, which will contain the name of the user who booked the appointment form the admin.

    Hope this is close to what you need :slight_smile:

    If you are not familiar with mu-plugins, you can read more about them here :

    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    or add that snippet in your child theme’s functions.php file

    Kind regards!

  • Nithin
    • Support Wizard

    Hi John Neilson,

    I tested the code shared by Panos in my system, and it works fine, and does list out Removed, and Completed Appointments without any issue.

    This looks more like a conflict with existing plugin, could you please temporarily disable all the plugins except WPMU DEV Dashboard, and Appointments+ plugin, and then check whether the above code works, or not?

    This would give a better idea where the issue is located, so that we could see what could be done to correct this. If you still have issues even after running the mentioned test, then please grant support staff access so we could give a closer look.

    You can grant access from WPMU DEV > Support > Support Access > Grant Access, or check this manual: https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-5

    Please let us know once you enable access, so that we could get this sorted. Have a nice day. :slight_smile:

    Kind Regards,

    Nithin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.