WordPress plugin Write User/staff ID as the same as the WordPress User ID

I have a question in regards to a WordPress plugin (Bookly) that creates a Staff ID for an already created WordPress user, and hopefully, somebody may be able to help me with.

Currently Bookly adds the Staff ID incremental so each new staff ID would say Staff ID:4 then the next 5 then 6 etc, I'm looking for some code that would take the current WordPress user's ID and add that ID as the Staff ID for that user when they are creating a Staff ID for them.

Any help much appreciated.

Thanks Ryan

Topic id url-rewriting users Wordpress

Category Web


function get_user_by_staff_id($user_ID) {

    $results = $wpdb->get_results("SELECT id FROM wp_ab_staff WHERE wp_user_id = '$user_ID' LIMIT 1 ");

    $staff_id = $results;

    return $staff_id;
}

Add this to your functions.php (not Booklys!!)

Then to use it you can do this:

 <?php echo do_shortcode('[bookly-form category_id="1" service_id="4" staff_member_id="'. get_user_by_staff_id(**USER ID HERE**) .'" hide="categories,services,staff_members,week_days"]'); ?>

Because the database table is set up to auto increment then you can't change the ID to match user ID without redesigning the database tables. This would be fine except you wouldn't be able to update the plugin without remaking the changes each time.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.