admin管理员组

文章数量:1122846

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

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

Share Improve this question edited Oct 9, 2017 at 16:29 rudtek 6,3535 gold badges30 silver badges52 bronze badges asked Oct 9, 2017 at 14:19 Ryan Mc GonagleRyan Mc Gonagle 315 bronze badges 1
  • did you ever find a solution to this? I have the exact same problem. – M0rty Commented Jun 20, 2019 at 23:55
Add a comment  | 

2 Answers 2

Reset to default 0

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.

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"]'); ?>

本文标签: url rewritingWordPress plugin Write Userstaff ID as the same as the WordPress User ID