Thursday, 26 December 2013 15:50

how to delete a option in wordpress

Written by 
Rate this item
(0 votes)
It's sometimes needed to delete a plugin option of your plugin.
It's a necessity too when plugin is activated or deactivated
this is easy to call -

delete_option( 'general_settings' );  
delete_option( 'color_settings' );

But it's quite important to do that when plugin is deactivated,
all you can do is call the above deletion functions under plugin
deactivation hook -

register_deactivation_hook(__FILE__, 'plugin_deactivation');

function plugin_deactivation(){  
if ( ! current_user_can( 'activate_plugins' ) )
  return;   
delete_option( 'general_settings' );
   //.............more
}
Read 2811 times Last modified on Thursday, 26 December 2013 15:54
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.