2

現在ソーシャル エンジンで表示しているプロファイルの user_id を取得しようとしています。
これは、現在ログインしている user_id です。

echo Engine_Api::_()->user()->getViewer()->getIdentity(); //currently logged in user_id

現在表示しているプロファイルの ID を取得するための構文は何ですか? ありがとう

4

2 に答える 2

1

'view-ee' (つまり、サブジェクト) を取得するには、次を使用できます。

最初にサブジェクトがあることを確認してから、そのユーザーの ID を取得することをお勧めします。

if(Engine_Api::_()->core()->hasSubject()){
    $user_id = Engine_Api::_()->core()->getSubject()->getIdentity());
} else {
    echo 'no subject on this page';
}

ブログでは、特に socialengine に関する多くのトピックを取り上げてきました。下記参照;

http://garbtech.co.uk/socialengine-creating-widgets-for-user-profiles-getting-the-subject-rather-than-the-viewer-information/

于 2012-08-29T10:15:10.950 に答える