I made a few custom fields on the registration form. I’m able to pull the data with get, but when I try to use conditionals the page breaks. Won’t save, won’t update, won’t load, I literally have to delete the page from the dashboard and start over.
Here is the code I’m hacking on unsuccessfully … is it possible to do what I’m attempting to do or am I just doing it wrong?
This works: Profile membership level: [s2Get user_field=“membership-level” /]
These don’t:
[s2If
membership_level(Home-based Business)] Some words
[/s2If]
[s2If
user_field_membership_level(Home-based Business)] Some words
[/s2If]
First, always copy and paste any code from the web into Notepad to strip off any crazy formatting. Then copy and paste that to your site. If you ever see squiggly quotes and not ’ or " then fix them. That should solve lots of errors. Not saying that’s an issue here, but it’s good practice.
I went to one of my functioning sites and found this. Hope it helps. I’ve never tried the shortcodes you’re trying.
Oh, understand… What you want needs some custom code - you must build the PHP function, that will compare the custom field’s value to some string, look at this hack. If you need a developer, please find me.
Thanks. I’ll see if my husband can take a crack at it. I may go in search of another platform tho. This one seems to have been abandoned by the developers from the forums I read last night
I’m wondering why it pasted like that if you copied it from your site. Maybe there are crazy invisible characters that made it look like, but not really be, on the same line. Did you originally write it in Word? That always puts invisible crazy characters in. I’d try copying and pasting to notepad (or similar) and then copying and pasting back.
And the plugin was only formerly abandoned. @clavaque is in charge now working on updates.
<?php
$fields = json_decode(S2MEMBER_CURRENT_USER_FIELDS, true);
if ($fields['membership_level'] == 'Home-based Business') { ?>
Some words
<?php } ?>
Having said that, why have the membership level as a custom field? Why not use the s2Member Level or a custom capability? And if you use these, you can use s2If for your conditionals.
To answer this question, we have different membership levels but want people to be able to register initially with a free account, which defaults to level 0. I don’t see a way for them to be able to choose what membership level they want to upgrade to other than clicking on the associated paypal button, and I don’t want the page cluttered with a bunch of buttons. So this way I figure I can display the appropriate subscription modification button based on the information I gathered when they registered. That said, the paypal subscription modification buttons don’t seem to work, so maybe you can tell me a better way to do it