Hi, i have search the whole forum and internet and could not find this issue. the solution available here does not work: http://manual.amember.com/AMember_Session_Variables it do not return any value for subscription plan. is there another way? or do i have to use pure mysql php command to access this? cause the later seem like i'm hacking my own system....................... regards
What version are you using?? If V4 then look at http://www.amember.com/docs/API/Lite and there are ways to do most things. What information are you trying to discover exactly?
that was clearly a bad idea, as i am calling this from within amember system iteself and not from an external script.
hi, sorry, this function is confusing: Am_Lite::getInstance()->haveSubscriptions($search) for $search if i use array(1,3), do the script search from plan with id 1-3 or 1 and 3? like this: Am_Lite::getInstance()->haveSubscriptions(array(1,3)) regards
Anyone ever figure this out? Any suggestions on the correct syntax (array, etc) when there is more than one subscription? I keep trying to figure it out but am stuck.
@dale_sellers need more info. Are you trying to get details from your own script or from say within aMember system in 'site.php' file? http://www.amember.com/docs/API/Lite is for your own scripts not within aMember.
I am using the same code as mentioned by chmava in this post, in a php page of my site: Code: Am_Lite::getInstance()->haveSubscriptions(array(1,3)) With one subscription and without the array, the code works great. But with 2 or more, it breaks. I'm just wondering about the correct syntax would be when using 3 subscriptions. Thanks for any suggestions.
Can you post up all of the code? I wanted to check arrays for two possible products when adding a tab, in site.php script, and split them to into two PHP: if (in_array (2 , $user->getActiveProductIds()) OR in_array (6 , $user->getActiveProductIds())) so wondering if you could split yours if you were using an 'if' statement for instance PHP: if (Am_Lite::getInstance()->haveSubscriptions(1) OR Am_Lite::getInstance()->haveSubscriptions(1) )
I realise this thread is probably too old now, but just in case it's useful to someone in the future... If checking from within aMember (i.e. plugin or site.php) you can use something like this: PHP: $activeProductIds = Am_Di::getInstance()->user->getActiveProductIds();if (in_array('3', $activeProductIds)) { // Has subscription to product 3, so do something...}if (array_intersect(array(1,6), $activeProductIds)) { // Has subscription to either product 1 or 6, so do something...} If checking from within WordPress, you can query via the aMember plugin. Here's a function I wrote that you can put into your functions.php that lets you query subscriptions. (The advantage of using a function in your theme is that you have a single point of change if the plugin changes, plus you don't kill your theme if you delete the aMember plugin PHP: /**** Check if user has active amember subscriptions** @param int|array $search* @return bool*/function am4_has_amember_subscriptions($search='any'){ if (!class_exists(am4PluginsManager)) return false; return am4PluginsManager::getAPI()->haveSubscriptions($search);} To call the above function in one of your theme pages, use something like: PHP: if ( am4_has_amember_subscriptions( array(3,1,5,7,12) ) ) { // Has one or more of subscriptions 3, 1, 5, 7 or 12, so do something...} If calling from some other PHP script, you can use AM_Lite using something like: PHP: // Check login$search = array(12,4,9,10,13,5);require_once '/home/path/to/amember/library/Am/Lite.php';if ( Am_Lite::getInstance()->haveSubscriptions($search) ) { // Do something} Cheers Rob
@robw - I just stumbled across this again. Your WordPress suggestion seems like a great option. Unfortunately, the 3rd code block you pasted seems to be throwing errors for me. My editors are saying there is a syntax error of some kind (extra parenthesis). I've been trying to play with it, but no luck? Of course, I'm no coder by any means. Is there is an error in what you posted, do you have an idea for a fix? Thanks for any clarification.
There is no problems with code in that block. Can you attach full source code and exact error message?
@alexander - Thanks for the reply. I'm sure it's probably some error on my part, but I am trying to use this in one of my WordPress theme files: Code: <?php if ( am4_has_amember_subscriptions( array(3,1,5,7,12) ) { // Has one or more of subscriptions 3, 1, 5, 7 or 12, so do something... } ?> I keep getting message from editor say there is something wrong with the " {" in line 2. So if I was to put this in a theme file, what should it look like? Thanks for any help.
Try this: PHP: <?phpif ( am4_has_amember_subscriptions( array(3,1,5,7,12) ) ) {// Has one or more of subscriptions 3, 1, 5, 7 or 12, so do something...}?> There is one missing ) in your code
I need to sharpen up - I should have seen that missing ) Anyways, seems to work now. I have this and just wanted to make sure it's a correct way to use code: PHP: <?phpif ( am4_has_amember_subscriptions( array(3,21) ) ) {{} ?><p>some text that will show here for 3 and 21</p><?php}?> Thanks for any clarification.
No that code is incorrect. Here is how it should be: PHP: <?php if ( am4_has_amember_subscriptions( array(3,21) ) ) : ?><p>some text that will show here for 3 and 21</p><?php endif; ?>
Alexander should the ':' in line 1 [( am4_has_amember_subscriptions( array(3,21) ) ) : ?>] not be a ';'?
Hi Dale, Just to pick up on the alternative syntax comment - Alexander was saying that there was an error in your code as posted. You can use regular parenthesis notation too, its just that what you had posted had an error. Here it is with correct syntax: PHP: <?phpif ( am4_has_amember_subscriptions( array(3,21) ) ) {?><p>some text that will show here for 3 and 21</p><?php}?> Cheers Rob