Applying Member Tags and displaying different content for each tag
I want to display different content depending upon what member tag is assigned to a member.
When they hit my application page for the first time I want the tag 'application-started' to be added to that member. On that page is a 3rd party form. Once this form has been submitted and the entry has been received - the system admin will then go and remove the tag 'application-started' from that persons account and add 'application-received'. Now when that member visits the application page they should no longer see the application form and instead should see whatever is in perch_content('Application Received');
So I only want the content for that member tag to be displayed and all other content for other tags to be hidden.
Now the way I currently have it configured below isn't working and it just keeps adding the Member Tag 'application-started' alongside any other tag e.g. 'application-received' and keeps showing them the application form. I'm guessing I can't have 'perch_member_add_tag('application-started');' under else.
Any help would be very much appreciated.
Thanks
<?php
if (perch_member_has_tag('everything-complete')) {
perch_content('Everything Complete');
} if (perch_member_has_tag('payment-pending')) {
perch_content('Payment Pending');
} if (perch_member_has_tag('application-accepted')) {
perch_content('Application Accepted');
} if (perch_member_has_tag('application-rejected')) {
perch_content('Application Rejected');
} if (perch_member_has_tag("application-pending")) {
perch_content('Application Pending');
} if (perch_member_has_tag('application-received')) {
perch_content('Application Received');
} else {
perch_content('Application Form');
perch_member_add_tag('application-started');
}
?>
just add the different tags as each step is completed then test for the tag. Might be best if you set the tags to expire rather then removing them... because if the member has not logged out then sometimes the tags may be persistent and will cause you headaches in the future.
I don't really want to set expiry dates. Each member will only likely be in each stage for a few days.
The problem I'm having .. is that even if I remove the tag 'application-started' and add one of the others 'application-received' when I go back to the page 'application.php' that displays the content .. it keeps re-adding the initial tag 'application-started' and shows me the content that's in my else bit of the statement .. when I'd like it to not show this and to show the perch content that I've added for the tag 'application-started'
Hope that makes sense? I'm guessing there's an issue with my if statements
If they're moving through a process you could just use the last-matching case.
Ok I've implemented your solution.
Issue I'm having now is that even though I have 6 Perch regions on the page. It's only letting me define and add content for one in Perch Admin. So when visit the page and then view the [age in Perch admin. It's only picking up one region and allowing me to select one template. So say for instance I select 'Application Form' then my members are seeing that and only that
How can I get access to all of these regions and add content to them. At the moment. No matter what tags are added to a members account. They are only ever seeing the application form.
You should use
perch_content_create()
to create the regions.https://docs.grabaperch.com/functions/content/perch-content-create/
Robert it right. Add it to the
for
loop.UNTESTED... sorry
I didn't think of doing that guys. I took the long road - Only just sen the two messages above
What I did below worked anyway. It allowed me to create the regions and add content.
I'm logged in as a member that has the Member Tag 'application received' on their account. But when I visit the page I'm still seeing the application form?
No matter what tag I have assigned. I am only ever seeing the Application Form???
this line in your code is the reason
$chosen_region = 'Application Form';
I kinda guessed that. But I thought that If I took it out then no-one would see the Application form. I only want the application Form Region to show if no tags are assigned
then add
else
statement toif (perch_member_has_tag($tag))
Thanks Robert. I'm almost there I know. But getting an unexpected else error now
I thought about just having the application form as a step too and adding a member tag when someone registers and initially becomes a member.
But now I'm getting a message rendering to my page saying:
You must pass in a name for the content. e.g. <?php perch_content('Phone number'); ?>
if your going to do it this way then you need to add the tag
application-new
before the$steps
otherwise your not going to get a region name returned fromforeach
Yes - this doesn't seem to be working :( I don't particularly want to do it this way but I couldn't get the else statement to work. Was giving me an error. I'm proper confusing myself now - and I know this is relatively simple stuff
make sure your clearing the cookies on your test member before you test code changes... either by removing the p_m cookie in the browser or
perch_member_logout()
and then log member back in...Otherwise you may be fighting the session cookies... and throwing away working code.
Ahh - Didn't know this.
Does the syntax on this look correct to you:
is another way to do it...
It will still only slow my Application Form regardless of what tags are attached to the member :/
you need to make sure your assigning new tags at the top of your code, if you assign new tags as admin to a signed in user those tags will not effect the user till they logout and login again because the session has already been written.
This is why its so important to make sure you delete the p_m cookie when testing your code on a member
it will force a new session