MyBB Community Forums

Full Version: Variable question please
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I searched and learned from the Mycode threads, but still need some help.

This works fine to build a url based on user input:

\[ma\](.*?)\[/ma\]

<a href="http://example.com/a/$1">$1</a>

Now I need to add a variable from the custom profile fields:

<a href="http://example.com/a/$1?$post['fid7']">$1</a>

or

<a href="http://example.com/a/$1?{$post['fid7']}">$1</a>

Neither one will work...

Since this type of variable " {$post['fid7']} " works in MyBB templates, I'm needing to know how to use it in a MyCode built URL also.

Thanks

////////
EDIT:
OK forget the details...

Can someone please, show any example of using an 'available' MyBB variable in custom MyCode?

Thank you
You can't use variables for the custom MyCode section unfortunately - you'll need a plugin for that.

BTW, be wary of:
\[ma\](.*?)\[/ma\]
That allows a bit of a HTML injection, if the user enters something like
[ma]abc" style="font-size: 200pt;[/ma]

I recommend something like this instead:
\[ma\]([^<>"]+?)\[/ma\]

Hope that helps.
(2008-10-20, 10:57 PM)ZiNgA BuRgA Wrote: [ -> ]You can't use variables for the custom MyCode section unfortunately - you'll need a plugin for that.

BTW, be wary of:
\[ma\](.*?)\[/ma\]
That allows a bit of a HTML injection, if the user enters something like
[ma]abc" style="font-size: 200pt;[/ma]

I recommend something like this instead:
\[ma\]([^<>"]+?)\[/ma\]

Hope that helps.
I did read about the security danger, and really like getting the exact code now.

Helpful plugin = Tiki's (Ryan) name plugin can do some of what I wanted, and I'll see about (safely) changing it for other variables.

Thanks Zinga Smile