InMotion Hosting Support Center

When you create a WordPress plugin, and you're already saving WordPress plugin settings with a form. You want to register those settings and store them in the database with WordPress, so it can change your site.

Register plugin settings with WordPress

We want to take the info entered by a plugin user, and store it into the WordPress database. To do this we need to register our setting changes with WordPress so it can store this information in the wp_options table.

Add add_action hook to register settings

When you create a WordPress admin menu you can add an add_action function after the add_menu_page function. This call another function update_extra_post_info to save info to the database from our form.

  add_menu_page( $page_title,
                 $position );

  add_action( 'admin_init', 'update_extra_post_info' );

Register settings with register_setting function

Creating a function called update_extra_post_info you can use the WordPress register_setting function to store info from our form into the database. The value will be stored next to extra_post_info in the wp_options table.

if( !function_exists("update_extra_post_info") ) {
function update_extra_post_info() {
  register_setting( 'extra-post-info-settings', 'extra_post_info' );

Plugin settings now saved to WordPress database

When you view your plugin page, you can see that when EXTRA INFO is entered into our settings, it ends up in the WordPress database beside extra_post_info. When this info is updated, so is the database entry.

extra post info admin page register setting in database

Read WordPress plugin settings from database

With your plugin settings saved in the database, the next step is to read WordPress plugin settings from the database to complete your plugin.

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

Social Media Login

Social Login Joomla

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2017-08-03 8:15 am

You are GREAT!

It is soo easy when reading this tutorial! 

n/a Points
2016-09-13 3:05 pm

Thanks a million.

n/a Points
2015-08-12 3:12 am

Thanks dude, that helped me a lot

40,371 Points
2015-08-12 10:02 am
Hello Green,

You're welcome! Remember to check out the WordPress Education channel for more information.

If you have any further questions or comments, please let us know.

Arnel C.

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

4 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!