Posted inTechnology / php / Programming / wordpress

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.

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.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype