admin管理员组文章数量:1327118
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
1 Answer
Reset to default 2Wordpress 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
版权声明:本文标题:Can you Use the Rest API to query a custom database table 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742201658a2432073.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论