MyBB Community Forums

Full Version: Show HTML only if user enabled it in profile
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'd like users to enable some HTML (an AJAX chat) only if they have enabled it in their profile.

Edit: The HTML would be visible on EVERY page.

How do? Angel
Could you explain a little bit more?

Do you want a shoutbox/chat system?
I apologise.

I already have a shoutbox system and I don't want another one. I just need it to be displayed on every page but only if you enable it in your profile. I'm going to be using an iFrame (but it'd be handy just to have code to allow any HTML, not just an iFrame on every page)
So you have a shoutbox, but you only want it displayed if the user checked "Yes, I want to see the shoutbox" in their profile
Yes, exactly. The shoutbox would be displayed on every page if they enable it.
What shoubox plugin are you using?
AJAX Chat

I don't plan on changing it, if that's what you're thinking.
Hmmm, ok. Can you install the Template Conditionals plugin?
If so, install it, and make a new radio button profile field with "Yes" and "No" for options.

Add to your header/footer template (wherever you want it)

<if $mybb->user["fidX"] == "Yes" then>
*AJAX chat iframe*
</if>

Change X in fidX to the profile field number.
I found that PHP tags in templates plugins but didn't use it because it opens up a security hole. Thanks for the link to the restricted plugin, I'm sure it'll do the trick.
When I try to view my plugins, half the page is blank. I'm assuming there's a php error somewhere, but I don't have access to my log files here.
It's a few days later, but I got it working. Thank you.