I want to know which hook/action is called just before the Text Widget content and title is stored in the database. I googled alot but could not able to get the hook name.

What I want is whenever a text widget save button is trigger (in admin panel) I want to apply my custom content customize function and the return the updated content so that WP can saves it.

Please Note: My question is not a duplicate of this question, because it deals with filter and I'm looking for hook or action. It can be a one solution but is not a good solution in my case, because it'll a time consuming.
For example: I have 10 active text widget in my sidebar and for every page hit on each widget render widget_text will be called. So I'm looking for a better solution.

Any help would be greatly appreciated.

  • grrr you complain about the answer before it was even given :((. In general if you need different behaviour you should write your own "text widget" as there are all kinds of hooks triggered when a widget is saved but they are not likely to be easily used. Jan 22, 2017 at 4:54

1 Answer 1


Not sure what you're after here, another options maybe possible, but there's e.g. this hook:

 * Filters a widget's settings before saving.
 * Returning false will effectively short-circuit the widget's ability
 * to update settings.
 * @since 2.8.0
 * @param array     $instance     The current widget instance's settings.
 * @param array     $new_instance Array of new widget settings.
 * @param array     $old_instance Array of old widget settings.
 * @param WP_Widget $this         The current widget instance.
 $instance = apply_filters( 

Here's an example how we can target Text widgets and modify the text input field, when they are updated:

add_filter( 'widget_update_callback', function( $instance, $new, $old, $obj )
    if( 'text' === $obj->id_base && ! empty( $instance['text'] ) )
        // Warning this overrides the widget instance text input:
        // $instance['text'] = 'override text';

    return $instance;
}, 10, 4 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.