Get user id for delete and update selected user

I’m trying to create admin form which can perform user creation, update and delete from frontend, See attached Screenshot
i’m trying to update user from update button but i’m little confuse how to get id for that perticular user in this list, There are also column for ID but actually i can’t understand the flow of this process. If anyone has idea than please share, Thanks in advance.

This is the code

<?php
  /*
  Plugin Name: Test Plugin
  */
    
    add_action('wp_enqueue_scripts', 'ajax_dealer_scripts');
    function ajax_dealer_scripts() {
        wp_enqueue_script('ajax_dealer_scripts');
        wp_enqueue_script('custom-js', plugin_dir_url( __FILE__ ). 'js/ajax-dealers.js', array('jquery'));
        wp_register_script( "house_doctor_inventory_script", plugin_dir_url( __FILE__ ).'js/ajax-dealers.js', array('jquery') );
        wp_localize_script( 'ajax_dealers_localize_scripts', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
    }
    
    add_shortcode('ajax_dealers', 'boxer_ajax_operations'); 
    function boxer_ajax_operations($userlevel="all", $show_fullname = true) { 
        global $wpdb;
        global $current_user, $wp_roles;
    
        $user_info = get_users( array( 'role__in' => array( 'standard_dealer', 'special_dealer' ) ) );
        // echo '<pre>';
        // print_r($user_info);
        // exit();
        ?>
        <table style="width:100%">
        <thead>
            <tr>
                <th>ID</th>
                <th>Username</th>
                <th>Email</th>
                <th>Update</th>
                <th>Delete</th>
            </tr>
            <thead>
            <tbody>
                <?php
                    foreach ( $user_info as $dealer ) { ?>
                    <tr>
                        <td><?php echo $dealer->ID; ?></td>
                        <td><?php echo $dealer->display_name; ?></td>
                        <td><?php echo $dealer->user_email; ?></td>
                        <td width="10%"><button class="button" id="update-dealer">Update</button></td>
                        <td width="10%"><button class="button" id="delete-dealer">Delete</button></td>
                        </tr>
                    <?php }
                ?>
            <tbody>
        </table>
    
        <form id="update-dealer-form" style="display:none">
            <label for="dealerUserName">Username</label>
            <input type="text" name="dealerUser_name" value="<?php the_author_meta( 'first_name', $current_user->ID ); ?>">
            <label for="dealerEmail">Email</label>
            <input type="text" name="dealerEmail">
            <input type="submit" value="Update" id="btn-update-dealer">
        </form>
        <script>
            jQuery(document).ready(function() {
                jQuery(document).on("click","#update-dealer", function() {
                    jQuery("#update-dealer-form").toggle();
                });
            });
        </script>
    <?php
    }

0

Leave a Comment