MyBB Community Forums

Full Version: Conditionals and profile fields
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Well recently I got Twitter logins working on my forum, and I thought it would be cool if I added a link in a user's control panel asking them to connect their account to Twitter to make logins easy, while hiding the message if they already have. I'm trying to do this with PHP Conditionals, but I think I'm doing something wrong:

<if !empty($post['fid13']) then><strong>Connect with Twitter:</strong> <a href="{$mybb->settings['bburl']}/twlogin.php">Connect your account</a> to Twitter to make future logins easy!<br /></if>

Profile field 13 is the field in which the Twitter login system put whether the user had connected/registered their account with Twitter, and it has two states, either "Yes" or empty.

The code above isn't working, so could someone tell me what I'm doing wrong?
Well you're trying to run PHP conditionals in HTML code.

Try something like:
<?php
if (!empty($post['fid13']))
{
     $fieldToOutputContent = "<strong>Connect with Twitter:</strong> <a href=\"{$mybb->settings['bburl']}/twlogin.php\">Connect your account</a> to Twitter to make future logins easy!<br />";
}
else
{
    #Run the code that would run if the twitter field returned true as empty()
}?>
That didn't work Sad

Using the same method as the code I posted, I set up a welcome block for guests on my forum. So I'm wondering if I have a variable such as the one that calls the value in the profile field wrong.
Well show me your exact code using the example I posted. That was just an example, it shouldn't really display anything.
I just used that code you gave me Toungue
Again, the code didn't work. I'm still needing a solution to this problem.
<if $post['fid13'] != "yes" then>
derp derp
</if>

?
(2011-07-20, 02:01 AM)Scoutie44 Wrote: [ -> ]
<if $post['fid13'] == "yes" then>
derp derp
</if>

?

Well the problem is I want the message to be displayed when the profile field is empty. Removing the "Yes" in the code (which was the first thing I tried) did not work.
Change the '==' to a '!=' then and try it again. If it doesn't work, you're doing something else wrong. Now, I'm assuming you have the Template Conditionals plugin installed ..?
(2011-07-20, 02:20 AM)Scoutie44 Wrote: [ -> ]Change the '==' to a '!=' then and try it again. If it doesn't work, you're doing something else wrong. Now, I'm assuming you have the Template Conditionals plugin installed ..?

<if $post['fid13'] != "Yes" then><strong>Connect with Twitter:</strong><a href=\"{$mybb->settings['bburl']}/twlogin.php\">Connect your account</a> to Twitter to make future logins easy!<br /></if>

Is that correct? It didn't work.

And yes I do have PHP Conditionals installed and working, that's how I made my welcome block Smile
Still need help.
Pages: 1 2