Skip to content
Advertisement

How to change the value of the input field of custom WordPress admin page?

I made a custom WordPress Admin page with input fields. I would like to change the values of them in the constructor based on the database. I have no idea how to access them…

The function which is called in the constructor and which will handle the database init. The database column names and input field ids are the same:

JavaScript

Field setup:

JavaScript

So I need to somehow access the fields outside the function.

Advertisement

Answer

The registered settings are stored in wordpress wp_options table by uid, you can access them using the get_option function. As your column name is same as your uid u can get the value of the field by get_option($column). You can update the values using update_option($column, $new_value).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement