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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
add_filter( 'wpdatatables_filter_formdata_before_save', 'filter_form_data', 10, 2 );
add_filter( 'wpdatatables_filter_formdata_before_save', 'filter_form_data', 10, 2 );
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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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);
// 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);
// 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);