Activating GeoIP collection programmatically | WordPress.org

[ad_1]

With a custom plugin I occasionally roll out changes where I don’t want to go through our sites manually. There’s rarely issues with that approach and I’ve done this with WP Statistics settings before as well. However, one option I seemingly can’t change this way is “GeoIP Collection” and I wonder why:

$wp_statistics = (array)get_option('wp_statistics');
$wp_statistics['geoip'] = 'on';
update_option('wp_statistics', $wp_statistics);

“on” is the literal value the plugin itself sets if the checkbox is activated. The only other corresponding value, “GeoIP Database Update Source”, is on JSDeliver from the get-go by default. I could imagine that just by setting the value the database wouldn’t be initially downloaded; is that it? Is there a way to activate this programmatically to the same effect as if it were activated manually?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer