Insert/Update values to a table after blogname option etc. is updated

Im trying to update into another table the values blogname, blog description options when the user updated them from General Settings page.

I use this code,

Read More
$hook_array = array('update_option_blogname','update_option_admin_email','update_blogdescription','update_option_home','update_option_siteurl');

foreach($hook_array as $hook)
{
    add_action($hook, 'my_functione', 10, 1);

}

function my_functione($arg)
{
    global $wpdb;
    $the_id = get_current_blog_id();
    $blogname =  get_option('blogname'); 
    $blogdescr =  get_option('blogfulldescription');
    $wp_blogs_info = $wpdb->base_prefix . "blogs_info";

    $wpdb->query("UPDATE " . $wp_blogs_info . " SET site_title=".$blogname.", site_description=".$blogdescr." where blog_id = '" . (int)$the_id . "'");

}

Here is the table,

  blog_id int NOT NULL,
  countries_id int(3) NOT NULL,
  site_title varchar(64) NOT NULL,
  site_description varchar(64) NOT NULL,
  site_tags varchar(64) NOT NULL,
  PRIMARY KEY (blog_id)

However, its not updating though there is a value with the blog_id of the current blog..
Please help.

Related posts

Leave a Reply

1 comment

  1. well, i just found that you’ve error in your query. i’ve re-written that for you:

    $wpdb->query("UPDATE `" . $wp_blogs_info . "` SET `site_title`='".$wpdb->escape($blogname)."', `site_description` = '".$wpdb->escape($blogdescr)."' where blog_id = '" . (int)$the_id . "'");