admin管理员组

文章数量:1326504

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?

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?

Share Improve this question asked Aug 9, 2020 at 14:08 petebolducpetebolduc 1294 bronze badges 2
  • 1 Duplicate of wordpress.stackexchange/questions/221808/… ? – Hans Commented 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 Commented Aug 9, 2020 at 14:30
Add a comment  | 

1 Answer 1

Reset to default 2

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.

本文标签: Can you Use the Rest API to query a custom database table