Hi Joachim,
Yes I’ve checked the api functions, though this is only to get data, not to set data.
What I do is simply hook into WP at a very early stage, store any info about the actual current user, and then “trick” WP and other plugins to run like it is a different user, or the user has other roles/capabilities.
So, previewing your plugin would work just fine when the user switches to an other user because everyting goes along with it.
But when a user switches to another role or changes his/her capabilities, your plugin will probably igore that to some level (though I need to test this..)
And most important: since I see that you are adding an extra type of “roles” as “levels” I’d like to simulate this aswell.
Codewise this would mean the following:
– I need to fetch a list of all available “levels” (hierarchical).
– Once a user selects a “level” to preview, I need to hook into RUA or WP at the stage where the current user’s access level is determined.
Not sure, but I guess this all happens in level.php.
get_user_roles
I could do this with a metadata filter on the user roles on get_user_by
.
get_user_levels
This one could be fine with a metadata filter as well, but I’d like to know if your meta handler will always store level ID’s instead of level names.
One thing I notice that this function accepts a $user_id
parameter. I’d say any filters should only work when the user ID is equal as this parameter.
_has_global_access
This one has a filter ??
I will make a new branche for this and will notify you. Could you help testing various use cases that RUA can do when I have it function to some degree?
Also, if I find any roadblocks, shall I make an issue and if possible a PR on GitHub?
Let me know what you think!
Cheers, Jory