We have created our own user dashboard that doesn't use the amember templates. We want to create our own version of "Active Resources", but cannot figure out how to get at the links. I have figured out how to pull active subscriptions, but not the associated URL. Can someone help?
Have you tried something like Am_Di::getInstance()->resourceAccess->selectAllowedResources( $user_id ); Then foreach the result as you desire
I get a script error when I try that. I've got a list of active products, but I can't get at the protected folder URL's of those products like active resources has.
PHP: <?php$email = 'jenolan@trexx.nampara';require_once dirname(__FILE__) . '/amember/bootstrap.php';$user = Am_Di::getInstance()->userTable->findFirstByEmail( $email );$res = Am_Di::getInstance()->resourceAccessTable->selectAllowedResources( $user );print_rr( $res ); You then need to process each asset, you should have the user record already ;-)
Thank you. That gets me closer as I get resource id's. From there, what API call do I need to get resource links?
Sigh I think you owe me a Kiva loan PHP: <?phpdefine( 'REL_ROOT_URL', 'http://jlogica.dev/amember' );$email = 'jenolan@trexx.nampara';require_once dirname(__FILE__) . '/amember/bootstrap.php';$user = Am_Di::getInstance()->userTable->findFirstByEmail( $email );$res = Am_Di::getInstance()->resourceAccessTable->selectAllowedResources( $user );print_rr( $res );$res = Am_Di::getInstance()->resourceAccessTable ->getAllowedResources($user, ResourceAccess::USER_VISIBLE_TYPES);print_rr( $res );echo '<pre>';foreach( $res AS $r ){ if( $l = $r->renderLink() ) { echo htmlentities($l); if( @$r->desc ) { echo ' :: '; echo @$r->desc; echo "\n"; } }}
This is great thank you! Does anyone know if this info is supposed to be returned via: Am_Lite::getInstance()->getUserLinks()
To get this info via Am_Lite::getInstance()->getUserLinks() please add the following code to site.php ( http://www.amember.com/docs/Site.php_file ): PHP: Am_Di::getInstance()->hook->add(Am_Event::AUTH_AFTER_LOGIN, 'mySaveLinks');Am_Di::getInstance()->hook->add('authSessionRefresh', 'mySaveLinks');function mySaveLinks(Am_Event $e) { $resources = $e->getDi()->resourceAccessTable->getAllowedResources($e->getDi()->user, ResourceAccess::USER_VISIBLE_TYPES); $links = array(); foreach ($resources as $r) { $link = $r->renderLink(); if ($link) $links[] = $link; } $e->getDi()->session->amember_links = $links;}