WordPress.org

Ready to get started?Download WordPress

Forums

User Access Manager
functions (11 posts)

  1. Dr_jAcKaSS
    Member
    Posted 3 years ago #

    Hi!

    Is there any function list of extended functions added by the plugin?

    I'm making my own navigation, so I would like to check for example to what group belongs current user.

    Best regards!

    http://wordpress.org/extend/plugins/user-access-manager/

  2. GM_Alex
    Member
    Plugin Author

    Posted 3 years ago #

    No I'm sorry but there isn't yet any function list. But you can look at the source code, I have commented all functions. I think you should look at the 'UamAccessHandler.class.php' file at the 'class' folder, there are function like 'getUserGroupsForObject' and you can use it like this.

    global $userAccessManager;
    $uamAccessHandler = $userAccessManager->getAccessHandler();
    $userGroupsForUser = $uamAccessHandler->getUserGroupsForObject('user', $userId);
  3. intrinicity
    Member
    Posted 3 years ago #

    Hi, Can you show mw how to "link" to these functions? I've tried to include the UamAccessHandler.class.php file and require_once (apologies, for my PHP ineptitude, I normally speak AS3 :).

    I too, am doing my own navigation (in Flash) and I simply want to use the checkObjectAccess() function in a post-getting loop to make sure it's display is permitted. The plug-in works a treat in native WordPress but I can easily bypass it using get_posts() in my external php file (it returns all the posts, regardless).

    Am I going about this the right way?

    Dave

  4. sitegefuehl
    Member
    Posted 3 years ago #

    Hi!
    I have the same question. I need a function for my template, which returns the uam group from current user. I tried your solutions, but i doenst work.

  5. GM_Alex
    Member
    Plugin Author

    Posted 3 years ago #

    Hi,

    the code works I have tested it. It the UAM plugin is active just add these lines of code above. Don't forget to set a valid user id at $userId. require_once or other includes are not necessary. A better version of the code is this:

    global $userAccessManager;
    
    if (isset($userAccessManager)) {
        $userId = $user_ID;
        $uamAccessHandler = $userAccessManager->getAccessHandler();
        $userGroupsForUser = $uamAccessHandler->getUserGroupsForObject('user', $userId);
    
        print_r($userGroupsForUser);
    }

    One more example to get the user groups of the current post:

    global $userAccessManager;
    
    if (isset($userAccessManager)) {
        $postId = $post->ID;
        $uamAccessHandler = $userAccessManager->getAccessHandler();
        $userGroupsForUser = $uamAccessHandler->getUserGroupsForObject('post', $postId);
    
        print_r($userGroupsForUser);
    }
  6. sitegefuehl
    Member
    Posted 3 years ago #

    I already found another solution for my problem, but thanks for your answer. I'll try it if i need it again.

  7. Dr_jAcKaSS
    Member
    Posted 3 years ago #

    GM_Alex: Are you sure this works as you are saying?

    Because I get out an array of something like all properties and settings for the page instead of an array of usergroups' IDs.

    Preview of the first cide:
    array(1) { [1]=> object(UamUserGroup)#144 (13) { ["accessHandler:protected"]=> object(UamAccessHandler)#241 (8) { ["userAccessManager:protected"]=> object(UserAccessManager)#158 (8) { ["atAdminPanel:protected"]=> bool(false) ["adminOptionsName:protected"]=> string(15) "uamAdminOptions" ["uamVersion:protected"]=> string(5) "1.1.4" ["uamDbVersion:protected"]=> string(3) "1.1" ["adminOptions:protected"]=> array(32) { ["hide_post_title"]=> string(5) "false" ["post_title"]=> string(34) "Nimate pravic za dostop do strani!" ["post_content"]=> string(47) "Nimate pravic za ogled prispevka! [LOGIN_FORM]" ["hide_post"]=> string(5) "false" ["hide_post_comment"]=> string(5) "false" ["post_comment_content"]=> string(33) "Sorry no rights to view comments!" ["post_comments_locked"]=> string(5) "false" ["hide_page_title"]=> string(5)

  8. Dr_jAcKaSS
    Member
    Posted 3 years ago #


  9. Dr_jAcKaSS
    Member
    Posted 3 years ago #

    problems with computer, just delete

  10. Dr_jAcKaSS
    Member
    Posted 3 years ago #

    Ok, just ignore the previous post, it was very stupid from me.

    I have figured it out.

    code:

    global $userAccessManager;
    
    if (isset($userAccessManager)) {
        $userId = $user_ID;
        $uamAccessHandler = $userAccessManager->getAccessHandler();
        $userGroupsForUser = $uamAccessHandler->getUserGroupsForObject('user', $userId);
    
        foreach($userGroupsForUser as $element){
             print $element->getId();
        }
    }
  11. Davoron
    Member
    Posted 3 years ago #

    Hi GM_ALEX.

    I tried to get the access Group of a specific pages but I don't get proper responses from your uamAccessHandler.
    I read you plugin code and tried to debug by myself but cant get a step forward.

    I am on a Page and try to find out if the subpages are restricted or not.
    All I got back is a empty array.

    As far as I found out, my page_id is no in the subarray of objectUserGroups[$objectType][$filterAttr] by these time.

    To make thinks short:
    It would be cool if I could get a complete array of all Pages and Users and their group-ids without asking the Database by myself.
    To do so by myself is no problem for me but I think it could be unnecessary if you class have the Data already in it.
    Or does it not have?

    By the way you plugin runs like a charm and expect of the lack of comments your sourcecode is very good to read and I learned some thinks by do so! Thank you for the good work! Donations will follow! :)

    Davoron

  12. jynk
    Member
    Posted 3 years ago #

    found a short way of checking if the current user can access a page etc;

    [added to functions.php]

    function uamHasAccess($userID){

    global $userAccessManager;
    $uamAccessHandler = $userAccessManager->getAccessHandler();
    return $uamHasAccess = $uamAccessHandler->checkUserAccess();

    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic