Discussion in 'Customization & add-ons' started by ehassler, Aug 25, 2006.
But why do you need any link between?
well, I don't... but I don't see how I can authenticate for admins and for users in the same "if" statement without them being linked.
as I said, I need to check for 2 things - if the user has an active subscription OR if the user is admin before I can display them the content of this page...
and I figured out the first part of it (active subscription) but I can't figure out the second part (admin check)... and I need to pull those off in the same "if" statement... any ideas?
Please add your admins as users, and create a special hidden product for them, name it "Admin Access" for example.
Then you can check - if user has subscription to this product, it is admin.
see, that's what I don't get...
how do I create a user FROM an admin?
I have no problem with creating a new user, giving him the access to the one and only product that the site has (a subscription), and whatnot...
but what I do have a problem with is that when an admin logs into the admin panel, and the link to that page that check for active subscription is there in the left navigation menu, he is not logged in through the general members login (that all regular users see) and he will not be validated as someone with an active subscription... unless he goes through the trouble of logging in twice - once through the admin login, and once through the members login - and he's gotta do that every single time (a bit too much work for an admin).
there is no easy function in smarty that just checks if the user accessing the page is an admin?
also (in addition), what is the difference between these two functions (as far as "if" checks are concerned):
No. It is completely separate and it is good from security point of view.
it will give you the same results, but
first is list (array) of active products that user is subscribed to
second is common user status (if there is one active subscription, it is 1)
ok, so if
if (in_array(5, $smarty.session._amember_product_ids))
deals with one product, how would I define multiple products in that statement?
just so I can display certain member content to certain groups...
Are you wanting an AND statement or an OR statement? (if this group AND this group) (if this group OR this group)
aside from nesting if statements, something like this might work (untested)
$products=array('1', '2', '3');
$products=array('1', '2', '3');
nope, that function doesn't exist (array_values_in_array) apparently.
and I could do this by just adding AND statements, but is there a way to make it a one liner, sort of check if user is a member of either group x,y,z and if not, not show anything?
Hmm.. just tested that on my sandbox and it is working. Are you running PHP 5?
yeah, why? is that a problem with your code/compatibility?
Yes, I believe array_values_in_array was added in PHP 4.20, but covering my basis.
Some additional uses of it in this thread:
also, how would you perform this check in php files outside of smarty templates?
What a great post. I would like to do the same, but instead of searching which product they have already paid for, I would like to have a condition based on what product they are tried to purchase in the past.
In other words, I have many PENDING / NOT-PAID status customers who return to members.html. At the moment they see ALL products which I don't want. I only want to show them the price_id that they were initially interested in (or the product_id).
Once I can do that, then I'll be able to hide certain products from them by making custom purchase links like this:
This is how I understand it to work. Purchasing a product is a two-step process.
Step 1. Create membership account in Amember.
Step 2. Redirected to payment processor to complete payment transaction.
The user creates an Amember account on the first page of signup. They do this by providing a username/password email address. When they click continue/submit they are taking to the payment processor for the purchased product. At this point Amember will have done the following:
1. Add a member record to amember_members table.
2. Add a payment record to amember_payments table.
The payment record is marked as not completed. It will be marked as completed when payment transaction is completed. If user aborts at this point that will still have member record and an unfinished payment record.
If you know the members id, you should be able to get this information, then you can query the amember_payment table for that member_id and unfinished payments. The unfinished payment record contains the product_id that the user had started to purchase. So you basically have all the information you need to customize the products displayed if you can do the customization work yourself.
Separate names with a comma.