• ResolvedPlugin Contributor Jory Hogeveen

    (@keraweb)


    Hi Joachim,

    I’d like to add a compatibility module to the plugin View Admin As to support your plugin access restrictions.
    Where can I find some documentations? What are the available hooks?

    Thanks and let me know!
    Jory

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Joachim Jensen

    (@intoxstudio)

    That sounds great!

    Currently there is unfortunately no official documentation (lack of time), but you can find a simple API on the plugin page. Let me know more about how you’d imagined the plugins to work together, and I’ll see if it is possible right now, or if Restrict User Access needs some modification too.

    Plugin Contributor Jory Hogeveen

    (@keraweb)

    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

    Plugin Author Joachim Jensen

    (@intoxstudio)

    Without having checked it further, I think that if you “trick” WP to think that the current user is another, so eg. wp_get_current_user returns the mimicked user, then Restrict User Access will work without any changes.

    There might be a need for more filters though. rua/user/global-access makes it possible to bypass all restrictions/changed capabilities. By default, an administrator will get access to everything no matter what levels have been created.

    I do not check this forum on a regular basis, so yes, please create issues or PRs on GitHub. You can also contact me here: https://dev.institute/contact/

    Plugin Contributor Jory Hogeveen

    (@keraweb)

    Hi Joachim,

    Ok great, I’ve started a PR on GitHub with some API improvements I’ve found.
    https://github.com/intoxstudio/restrict-user-access/pull/8
    I’ve chosen to do everything with existing filters. What is the chance that meta keys will change in the future?

    I’m almost ready with a dev branche for this to publish. I’ll let you know!

    Are you also active on Slack?

    Thanks, Jory

    • This reply was modified 7 years, 11 months ago by Jory Hogeveen.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Integrate with View Admin As’ is closed to new replies.