2. endpoint function

Kotlin

functions.php

function save_customer(WP_REST_Request $request) {
    $name = $request->get_param('name');
    $phone = $request->get_param('phone');
    $pass = $request->get_param('pass');

    global $wpdb;
    $table_customer = $wpdb->prefix . 'customer';
    $customer_data = array(
        'name' => $name,
        'phone' => $phone,
        'pass' => $pass
    );
    $format = array('%s', '%s', '%d');
    $wpdb->insert($table_customer, $customer_data, $format);
}
BACK