I have managed to create my private messaging system, but now I want to make the user experience similar to both front-end users and to back end users.
What I have is a screen like gmail, which when clicked you can see the "conversation" and the form to make a reply. How can I have a wordpress plugin to handle this both on the admin site and on the front end site.
I remind that I have a custom admin solution, which can:
- Read wp-load.php
- Create wpnonce (as an extra security reason)
- Utilize wpdb for database (My messaging system is database build on, thinking on moving it on redis if it gets too bloated)
Actually I have set some things in a wordpress plugin; mainly I have made a plugin to have the private messaging system class available to front end and to back end but I don't know how to post (either traditionally or with ajax) from the back end and from the front end. Specifically, in my plugin folder there is a process.php file that is the target of the used for the PMS (either by POST or AJAX).
What should I do to have wp functions available there? Do I have to include wp-load as well?
Also specifically, since the only change in both backend frontend users would be the user id, how can I have a template rendering that would satisfy both the backend and the frontend? Do I have to make function calls to my plugin for rendering screens?
UPDATE
Since yesterday I've been trying to find a way for showing the elements in a common template (either by POST/GET or AJAX), which I see it cannot work, so I would utilize twig for maintaining a series of templates.
So now the real question is how can a user on the frontend (someone who is registered to wordpress with a role like customer, no admin rights) can post on process.php and a backend user (role:siteadmin, has full custom backend).
I have seen for a fact that in the plugin you can simply render a form by using a function like
// plugin code+definition
function doRenderForm() {
?>
<form method="post" action="">
<form elements>
</form>
<?php
}
[.. rest of plugin code ...]
and this can be called from the backend as well. But what I can't understand is what should I put to the action (what path?) so that it's seen common from both users.