1

ログイン アドオン (http://rtfm.modx.com/display/ADDON/Login) を使用しており、以下を使用してユーザーに関する情報を取得できます。

print_r($_SESSION);

しかし、そのユーザーのユーザー グループ (名前または ID) を取得する方法を考えています。誰もこれについてどうすればよいか知っていますか?ありがとう!

PS:print_r($_SESSION);私に何を与えるか:

Array
(
    [modx.user.0.resourceGroups] => Array
    (
        [web] => Array ( ) 
    ) 
    [modx.user.0.attributes]     => Array 
    (
        [web] => Array
        (
            [modAccessContext] => Array
            (
                [web] => Array
                (
                    [0] => Array
                    (
                        [principal] => 0 
                        [authority] => 0 
                        [policy]    => Array ( [load] => 1 ) 
                     ) 
                  )
            ) 
            [modAccessResourceGroup]       => Array ( ) 
            [modAccessCategory]            => Array ( ) 
            [sources.modAccessMediaSource] => Array ( )
        )
    ) 
[modx.user.contextTokens] => Array ( [web] => 2 ) 
[modx.web.user.token]     => modx507e2d531fedb5.20134124_250c977bed72111.66166942 
[modx.web.session.cookie.lifetime] => 0
[modx.user.2.resourceGroups] => Array ( [web] => Array ( [0] => 1 ) ) 
[modx.user.2.attributes] => Array ( [web] => Array ( [modAccessContext] => Array ( [web] => Array ( [0] => Array ( [principal] => 2 [authority] => 9999 [policy] => Array ( [load] => 1 [list] => 1 [view] => 1 [save] => 1 [remove] => 1 [copy] => 1 [view_unpublished] => 1 ) ) ) ) 
[modAccessResourceGroup] => Array ( [1] => Array ( [0] => Array ( [principal] => 2 [authority] => 9999 [policy] => Array ( [load] => 1 [list] => 1 [view] => 1 ) ) ) ) 
[modAccessCategory] => Array ( ) [sources.modAccessMediaSource] => Array ( ) ) ) ) 
4

1 に答える 1

2

これを読んでください - http://www.shawnwilkerson.com/modx-revolution/2012/03/10/programmatically-working-with-the-moduser-object/必要なコードのサンプル:

/*
* modUser Groups
*/
$arry = print_r($user->getUserGroups(), true);
$modx->toPlaceHolder('user.groups', $arry);
于 2012-12-13T10:51:43.017 に答える