jeudi 10 décembre 2015

Use global variable to store Data session

I am using a plugin which is Groups. This allows to handle groups, hierarchy and capabilities. Using this, I can restrict the access to post to some groups of users.

The API provided by this plugin has a Class which has a method giving me back all the accessible posts for the current user. I have to provide as parameters all the posts (via get_posts method) and the $wpdb.

As you can see, each time I call this method, queries are done, I really want to avoid it.

So, my question is what is the best way to handle it ?

A way should be to have a global variable (as SESSION, but I saw wordpress wasn't using it), in which I could store session variables as accessibles posts. I could initiate this variable with the wp_login hook.

I really want to do something safe.

Thanks everyone for reading :-)

Sommy



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire