...

View Full Version : Need help converting membership level number to name



sfraise
03-11-2009, 11:00 PM
I'm building a personals site based on the osdate cms and am having some trouble with what should be a simple tweak.

I've put together a script to pull the membership level using:


<b>Current Membership level:</b>
</td>
<td>
<?php echo $this->_tpl_vars['user']['level']; ?>
<a href="http://www.yoursite.com/custompaymentpage.php> <u><b>Give a membership upgrade gift to this member.</b></u></a>
</td>
</tr>


This will show as
"Current Membership Level: (1,2,3, or 4) Give a membership upgrade gift to this member."

Where 1=Gold 2=Silver 3=Visitor and 4=Free

How do I get this script to show the Gold, silver, Visitor, or Free instead of 1,2,3, or 4?

Do I need to set up an array to do this?

I've tried using variations of:


{if ($level=='1')}
<B> <font color="gold">Gold</font></B>
{/if}

{if ($level=='2')}
<B> <font color="silver">Silver</font></B>
{/if}

{if ($level=='3')}
<font color="gray">Visitor</font>
{/if}

{if ($level=='4')}
<font color="black">Free user</font>
{/if}

But I can't seem to get it to take.

I know this is probably super easy for a lot of you out there so any help would be greatly appreciated.

sea4me
03-11-2009, 11:10 PM
Try this:


if ($level=='1'){
echo '<B> <font color="gold">Gold</font></B>';
}

else if ($level=='2'){
echo '<B> <font color="silver">Silver</font></B>';
}

else if ($level=='3'){
echo '<font color="gray">Visitor</font>';
}

else if ($level=='4'){
echo '<font color="black">Free user</font>';
}

else{
echo 'Something wrong with user??? No level???? lol';
}

sfraise
03-11-2009, 11:59 PM
I tried:


<tr class="signup_line_outer evenrow">
<td width="50%">
<b>Current Membership level:</b>
</td>
<td>
<?php echo $this->_tpl_vars['user']['level'];
if ($level=='1'){
echo '<B> <font color="gold">Gold</font></B>';
}

else if ($level=='2'){
echo '<B> <font color="silver">Silver</font></B>';
}

else if ($level=='3'){
echo '<font color="gray">Visitor</font>';
}

else if ($level=='4'){
echo '<font color="black">Free user</font>';
}

else{
echo 'Something wrong with user??? No level???? lol';
}
</td>
</tr> ?>

But no luck, it just displays the something wrong after the level number.
Do I need to set this up in a <?php if (( $this-> string?

rafiki
03-12-2009, 12:50 AM
Try


<tr class="signup_line_outer evenrow">
<td width="50%">
<b>Current Membership level:</b>
</td>
<td>
<?php echo $this->_tpl_vars['user']['level'];
if ($item.level=='1'){
echo '<B> <font color="gold">Gold</font></B>';
}

else if ($level=='2'){
echo '<B> <font color="silver">Silver</font></B>';
}

else if ($level=='3'){
echo '<font color="gray">Visitor</font>';
}

else if ($level=='4'){
echo '<font color="black">Free user</font>';
}

else{
echo 'Something wrong with user??? No level???? lol';
}
?>
</td>
</tr>

sfraise
03-12-2009, 01:11 AM
This is what i'm using in my actual code, I forgot to place the ?> at the end as I copied it in sections.

Anyway, still not working. Beats the heck out of me.

If


<?php echo $this->_tpl_vars['user']['level']; ?>

works where level is the thing we're using, then why in the world doesn't


<tr class="signup_line_outer evenrow">
<td width="50%">
<b>Current Membership level:</b>
</td>
<td>
<?php echo $this->_tpl_vars['user']['level'];
if ($level=='1'){
echo '<B> <font color="gold">Gold</font></B>';
}

else if ($level=='2'){
echo '<B> <font color="silver">Silver</font></B>';
}

else if ($level=='3'){
echo '<font color="gray">Visitor</font>';
}

else if ($level=='4'){
echo '<font color="black">Free user</font>';
}

else{
echo ' error';
}
?>
</td>
</tr>

work?

What am I missing here?

Here's what it shows as it is:
Current Membership level: 2 error
The member has a silver membership so the 2 that get's displayed is correct, but it shouldn't display the 2, it should be converted to show as silver.
I'm guessing I need to set up some kind of <?php if (( $this-> string but I'm not sure exactly how to restructure it.

Fou-Lu
03-12-2009, 02:08 AM
o.O


<tr class="signup_line_outer evenrow">
<td width="50%">
<b>Current Membership level:</b>
</td>
<td>
<?php
$sColour = 'red';
$sType = 'Error!';
switch ($this->_tpl_vars['user']['level'])
{
case 1:
$sColour = 'gold';
$sType = 'Gold';
break;
case 2:
$sColour = 'silver';
$sType = 'Silver';
break;
case 3:
$sColour = 'gray';
$sType = 'Visitor';
break;
case 4:
$sColour = 'black';
$sType = 'Free';
break;
}
printf("<span style=\"font-color:%s\">%s</span>\n", $sColour, $sType);
?>
</td>
</tr>


The problem with what you have above is that the $level variable has not been defined.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum