I want to delete an option from the wp-options table when clicked on a button in the back-end.

i have created an option with this :

get_option( string $option, mixed $default );

is there any method in WordPress to get this done? i want to set it back to $default so basically deleting the $option

  • 1
    delete_option()? – Jacob Peattie Dec 5 '18 at 13:06
  • @JacobPeattie yh.thanks i was looking it , can it be triggered with button click? – Latheesh V M Villa Dec 5 '18 at 13:09
  • @JacobPeattie yeah duplicate thanks for the guidance – Latheesh V M Villa Dec 5 '18 at 13:13
  • @JacobPeattie i tried to put the delete_option() within the answer but it didn't deleted the option – Latheesh V M Villa Dec 5 '18 at 13:45
  • @JacobPeattie sorry it works ..but if i change form action to admin_url('admin-post.php'); my custom option page url it stops working – Latheesh V M Villa Dec 5 '18 at 15:16