how to use update option in wordpress plugin

how to use update option in wordpress plugin

Most of wordpress plugin writer choose the new table for saving data for plugin setting and any setting in wordpress plugin. In this article we will show, how to use update option in wordpress plugin.  I recommend to use the update option for saving data in wordpress database.

how to use update option in wordpress plugin

how to use update option in wordpress plugin
how to use update option in wordpress plugin

There is ready made option is provided by wordpress to save custom data in there table.

Here with very simple code I will show how use save the data in wordpress database.

< ?php
$variable = array(‘var1′ => $_POST['var1'], ‘var2′ => $_POST['var2']);
update_option(‘myPlugin_var1′, serialize($variable));
get_option(‘myPlugin_var1′) == “” ? “” : $new = unserialize(get_option(‘myPlugin_var1′));
?>

You should save data in simple variable format or I suggest always save data in array format.

For more reference you can check the following URL
http://phpxref.com/xref/wordpress/wp-admin/options.php.source.html

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

2 thoughts on “how to use update option in wordpress plugin”

  1. Hi, I’m very interested in Linux but Im a Super Newbie and I’m having trouble deciding on the right distribution for me (Havent you heard this a million times?) anyway here is my problem, I need a distribution that can switch between reading and writing in English and Japanese (Japanese Language Support) with out restarting the operating system.

Leave a Reply

Your email address will not be published.