Check if a user already add an appointment

Hello team !

I have a question that might be out of support range but I'm asking, maybe you already faced this and know a trick to help me go further in my dev :wink:

I would like to know if they is a way to check if a user already had an appointment once (or more) or if he never had one. Like an appointment counter something like that.

It would be helpful to export mail addresses from my database to my mailing system that way I can target users that never had or asked for an appointment !

Thanks for the info :wink:
Regards,
Guillaume

  • Vinod Dalvi

    Hi Guillaume,

    I hope you are well today and thank you for your question.

    We can develop custom code to check if a user already add an appointment but we can only do this if the user books an appointment as registered user and not as non registered user as shown in the attached screenshot so to overcome this we can force users to register on your site to book an appointment.

    Also we can't track the appointments which are permanent deleted and we can only track it if it is in either of the states Active appointments | Pending appointments | Completed appointments | Reserved by GCal | Removed appointments

    Please let me know whether you are comfortable with it so that i can help you to develop custom code to achieve this.

    Kind Regards,
    Vinod Dalvi

  • Guigro

    Hello Vinod !

    Thanks for this answer !

    My customer are all registered, otherwise they can't ask for an appointment. And that's great for non-permanently deleted appointment, I can deal with that. As once the export is done, if a user is in the "Already had an appointment list", during the next export I will delete him from the "never had an appointment list".

    Maybe an appointment counter will be fine that way there will be something to export users regarding the number of appointment they had. But a "yes or no" condition will be enough :slight_smile:

    Thanks !!

  • Vinod Dalvi

    Hi Guillaume,

    Thank you for your reply.

    To achieve this you can use the attached small plugin specially developed for you and then add the following shortcode in the post or page content where you want to display the user details.

    [display_app_user_details]

    It will display the output something like as shown in the attached screenshot based on the table styling of your site.

    Best Regards,
    Vinod Dalvi

  • Guigro

    Woow you developed a plugin just for me I'm blushing !
    Thanks a lot !

    To help other users, here is a code based on your custom plugin that I use to display this Appointment count in the User Table in WP-Admin :

    add_filter('manage_users_columns', 'app_count_column');
    function app_count_column($columns) {
        $columns['app_count'] = 'App+ Count';
        return $columns;
    }
    
    add_action('manage_users_custom_column',  'app_count_function', 10, 3);
    function $app_count_function($user, $user_id) {
    global $wpdb, $current_user, $bp, $appointments;
    $user = get_userdata( $user_id );
    	$results = $wpdb->get_results(
    					"SELECT * FROM " . $appointments->app_table .
    					" WHERE user=".$user->ID
    				);
    
    		return count($results);
    
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.