updated_option Wordpress hook details - WORDPRESS ACTION HOOKS

updated_option WordPress hook details – WORDPRESS ACTION HOOKS

Today, We want to share with you updated_option WordPress hook details – WORDPRESS ACTION HOOKS.In this post we will show you updated_option WordPress hook details , hear for UPDATED_OPTION in WORDPRESS ACTION HOOKS we will give you demo and example for implement.In this post, we will learn about wordpress get_option serialized with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

updated_option WordPress hook details – WORDPRESS ACTION HOOKS

There are the Following The simple About updated_option WordPress hook details – WORDPRESS ACTION HOOKS Full Information With Example and source code.

As I will cover this Post with live Working example to develop WordPress hook detect that option value has changed, so the some major files and Directory structures for this example is following below.

Example 1: UPDATED_OPTION in WORDPRESS ACTION HOOKS

public function hook_gsf_server(){
  //Update Blog Settings
  add_action( 'updated_option', array( $this, 'action_update_site_option'), 10, 3 ); 
}

function action_update_site_option( $option_name, $old_value, $option_value ) { 
      $blog_details = get_wp_shop_details();
      $url = "https://www.your_domain_name.com/admin/api/shop_information_hook";
      $request = wp_remote_post($url, array(
      'headers'     => array('Content-Type' => 'application/json; charset=utf-8'),
      'body'        => json_encode($blog_details),
      'method'      => 'POST',
      'data_format' => 'body',
      ));

      if( is_wp_error( $request ) ) {
      return false; 
      }

      remove_action( 'updated_option', array( $this, 'action_update_site_option' ), 10, 3 );
}

Example 2: WordPress Hook After Options Page Save

To run the hook, copy the example below.

run the action

do_action( 'update_option', $array ); 

The following example is for adding a hook callback.

define the update_option callback

function action_update_option( $array ) { 
    // make here action magic happen here... 
}; 

add the action

add_action( 'update_option', 'action_update_option', 10, 1 ); 

To remove a hook callback, use the example below.

remove/delete the action

 
remove_action( 'update_option', 'action_update_option', 10, 1 ); 

The dynamic portion of the hook name, $option, refers to the option name.

add_action( 'update_option_(option)', 'action_function_name_7854', 10, 3 );
function action_function_name_7854( $old_value, $value, $option ){
	// action...
}

Where is the hook used (in the core of WordPress)

add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 );
add_action( 'update_option_home', 'update_home_siteurl', 10, 2 );
add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 );
add_action( 'update_option_blog_public', 'update_blog_public', 10, 2 );
add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
add_action( 'update_option_admin_email', 'wp_site_admin_email_change_notification', 10, 3 );

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about update_option () in wordpress.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1.   get_post_meta in WordPress Example
  2.   Inline Table Editing Row using Vuejs
  3.   vuejs Manipulate Numbers Money Format
  4.   Laravel Eloquent Useful Tips and Tricks
  5.   VueJS setTimeout() Function Examples
  6.   PHP nested FOR loop multiple conditions - ArrayIterator
  7.   Simple Vue 2.0 Hello World Example
  8.   Wordpress Plugin uninstall hook - register_uninstall_hook()
  9.   Stripe API subscriptions with plan coupon and discounts using PHP
  10.   Install PHP Accelerator using Xampp