1

I am new to the wp platform and just learned about the Rest Api. I am creating a plugin that will allow the user to access a note keeping system which I plan to manage in a custom database table. Is it possible to manage the CRUD through the Rest Api or is the Rest Api reserved for the core WordPress database tables?

2
  • 1
    Duplicate of wordpress.stackexchange.com/questions/221808/… ?
    – Hans
    Aug 9, 2020 at 14:26
  • 1
    No, the REST API is not limited to the core WordPress tables, so what you can query on the front-end/public and admin sides of the site, can also be queried via the REST API.
    – Sally CJ
    Aug 9, 2020 at 14:30

1 Answer 1

1

Wordpress has no system of assigning privileges or access to control to code that runs in functions.php or in an enabled plugin.

Therefore if you can get code to run into functions.php or a plugin in your Wordpress environment, you can do anything that you can do in PHP in your web hosting environment, and this includes anything at all in Wordpress.

So in your case, once you make your REST API endpoint work, the PHP there can do absolutely anything. You could access the table through the $wpdb object to use Wordpress's database connection and database helper functions. Or you could if you wanted to write your own PHP from scratch using direct mysqli_ calls if you wanted -- this might be advisable if e.g. you would like some of your application logic to be independent from WP.

1
  • Do you think there is a plugin for this purpose? I mean a plugin, where I would set DB connection for a separate database and and then the plugin would provide a REST API endpoint for that database? Or would you advice to code a custom plugin?
    – meehocz
    Oct 9, 2020 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.