wpdatatables_filter_formdata_before_save

Contents

Description

This filter is applied to the filled out editing form before the entry is saved upon front-end editing.

Usage

add_filter( 'wpdatatables_filter_formdata_before_save', 'filter_form_data', 10, 2 );

Parameters

    • $formData arrray
      An associative array where the keys are the column identifiers from the front-end form, and the values are the data entered by the user.
    • $tableID integer
      ID of table from database.

Examples

// Callback function for the wpdatatables_filter_formdata_before_save filter hook
function filter_form_data($formData, $tableId) {
   // Check for specific table Id
   if ( $tableId == 1) { 
        // Check if the 'email' column exists in the form data and convert it to lowercase
        if (isset($formData['email'])) {
            $formData['email'] = strtolower(trim($formData['email']));
        }
    }

    // Return the modified form data
    return $formData;
}

add_filter( 'wpdatatables_filter_formdata_before_save', 'filter_form_data', 10, 2);