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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0