I want to write a plugin so that I can connect to it with an app bot, and store information inside the database.

Note that because I directly connect to php file inside this plugin, the public WordPress values like $wpdb are not known.

I can use only php code, and no ajax!

And how can i access to wp functions? such as get_option,...

thanks for your help.

  • 1
    And why do you want to create such file? Why not to create own REST API endpoints for example? – Krzysiek Dróżdż Nov 28 at 22:05
  • Having a PHP file inside a plugin that's loaded directly is a security risk, bad practice, and can cause issues. Use a REST API endpoint, or handle things on the init hook. There are lots of other alternatives, but don't do this – Tom J Nowell Nov 28 at 23:51
  • Thanks for your comments. I tried to use REST API, but I did not know how to save the data in the database. If you can get an example, thank you for your help. – Hamed B Nov 29 at 5:35

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.