insert( $wpdb->prefix . 'apt_clients', array( 'first_name' => $first_name, 'last_name' => $last_name, 'phone' => $C_phone, 'skype_id' => $C_skyp_id, 'email' => $C_email, 'notes' => $C_notes, ) ); $user_data = array( 'user_pass' => $user_pass, 'user_email' => $C_email, 'user_login' => $C_email, 'role' => 'subscriber' // Use default role or another role, e.g. 'editor' ); $user_id = wp_insert_user( $user_data ); add_action( 'admin_init', 'wp_insert_user' ); } //update customer if ( isset( $_REQUEST['u_C_phone'] ) && isset( $_POST['client_update_nonce'] ) ) { if ( ! wp_verify_nonce( $_POST['client_update_nonce'], 'client_update_nonce' ) ) { die(); } $u_use_id = sanitize_text_field( $_REQUEST['u_use_id'] ); $u_first_name = sanitize_text_field( $_REQUEST['u_first_name'] ); $u_last_name = sanitize_text_field( $_REQUEST['u_last_name'] ); $u_C_phone = sanitize_text_field( $_REQUEST['u_C_phone'] ); $u_C_skyp_id = sanitize_text_field( $_REQUEST['u_C_skyp_id'] ); $u_C_email = sanitize_text_field( $_REQUEST['u_C_email'] ); $u_C_notes = sanitize_text_field( $_REQUEST['u_C_notes'] ); $wpdb->update( $wpdb->prefix . 'apt_clients', array( 'first_name' => $u_first_name, 'last_name' => $u_last_name, 'phone' => $u_C_phone, 'skype_id' => $u_C_skyp_id, 'email' => $u_C_email, 'notes' => $u_C_notes ), array( 'id' => $u_use_id ) ); } //single delete if ( isset( $_REQUEST['single_id'] ) ) { $del = sanitize_text_field( $_REQUEST['single_id'] ); $wpdb->delete( $wpdb->prefix . 'apt_clients', array( 'id' => $del ) ); } // multi delete if ( isset( $_REQUEST['id'] ) ) { $id_array = sanitize_text_field( $_REQUEST['id'] ); $arr = explode( ',', $id_array ); echo $id_count = count( $arr ); for ( $i = 0; $i <= $id_count; $i ++ ) { $del = $arr[ $i ]; $wpdb->delete( $wpdb->prefix . 'apt_clients', array( 'id' => $del ) ); $wpdb->show_errors(); $wpdb->print_error(); } } ?>