applyFilters( “get_data” )

  1. Home
  2. Knowledge Base
  3. Codex
  4. JS API
  5. JS Filters
  6. applyFilters( “get_data” )
DiviArea.applyFilters( "get_data", value, key );
DiviArea.applyFilters( "get_data_{key}", value, key );

Filters a value that was just read from a Cookie or the localStorage. When no value exists (or it expired), the value is set to boolean false.

The {key} part in the hook name is the sanitized variable-name (all lower case, dashes changed to underscores).


(string|false) The value that was read from the Cookie or localStorage.
(string) The unsanitized variable name.


This filter is called inside DiviArea.Utils.getLocalData().


// Example 1: Return the string "no" instead of all boolean false values.
DiviArea.addFilter( 'get_data', function( value, key ) {
    if ( false === value ) {
        value = 'no';
    return value;

// Example 2: Output all local data to the console.
DiviArea.addFilter( 'get_data', function( value, key ) {
    console.log('Local variable', key, 'has value', value);
    return value;


No notes.

Was this article helpful?

Related Articles