MyBB Community Forums

Full Version: MyCode in Custom Fields
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I have a few custom profile fields set up via the ACP, but would like to better customize the look and feel of my forum by more specifically positioning each {$userfields['fidX']}. Unfortunately, when I separate the userfields from the customfields, this strips away the MyCode formatting options.

I have "Yes, allow MyCode in this profile field." selected but for some reason, it's not allowing it. How do I enable MyCode in the "userfields" on member profiles when I'm calling them individually?
You will probably need something like this, I can't recall what the difference between its original version is tough apart on that it requires PluginLibrary and is "updated" for MyBB 1.8.

Changing the compatibility line in the original version may work too.
There's no reason this shouldn't be a default functionality? If MyCode is set to parse when calling custom fields via {$customfields}, why on earth shouldn't it also parse when calling the specific field via {$userfields['fid1']}? Especially since HTML still parses fine when using $userfields??

ETA: In fact, it seems HTML parses in {$userfields['fid1']} regardless of whether HTML is enabled on the field or not. {$customfields} honors the setting for enabling HTML, but {$userfields} will parse it no matter what. :/
That is because you are using an uninitialized variable, which outputs raw HTML and MyCodes (plain). Meanwhile, $customfields gets through the parser.

I agree this should be core functionality but it isn't, and as such the plugin adds that feature.

In MyBB 1.9, shipping with a new template engine, might not require a plugin for this.
I have made a very small change in member.php to address this issue:

at line 2683 I added an array variable:
$parseduserfields = array();

and at line 2748
coming after $customfieldval = $parser->parse_message($userfields[$field], $parser_options);
$parseduserfields[$field] = $customfieldval;

this way if I use $parseduserfields instead of $userfields in my templates I can get parsed values regarding mycode.
(2020-08-13, 10:13 AM)joiSoi Wrote: [ -> ]I have made a very small change in member.php to address this issue:

at line 2683 I added an array variable:
$parseduserfields = array();

My line numbers don't match up to yours at all. Would you mind providing the 'before' like for this piece? I want to try this out, as I've had the same issue for a couple years now and I'm very excited by the possibility of having BBC back in my profiles xD
(2020-08-15, 07:41 AM)ThistleProse Wrote: [ -> ]
(2020-08-13, 10:13 AM)joiSoi Wrote: [ -> ]I have made a very small change in member.php to address this issue:

at line 2683 I added an array variable:
$parseduserfields = array();

My line numbers don't match up to yours at all. Would you mind providing the 'before' like for this piece? I want to try this out, as I've had the same issue for a couple years now and I'm very excited by the possibility of having BBC back in my profiles xD

Sure, it's right here:


$query = $db->simple_select("userfields", "*", "ufid = '{$uid}'");
$userfields = $db->fetch_array($query);
$parseduserfields = array();

// If this user is an Administrator or a Moderator then we wish to show all profile fields

...
But my mybb version is 1.8.21, so code might differ a bit with your version. Try not to break anything Big Grin
Hrm. Finally got to try this hack, and unfortunately it doesn't work for me. While it doesn't break anything, the fields changed from {$userfields['fidX']} to {$parseduserfields['fidX']} completely vanish on the front end.

	$query = $db->simple_select("userfields", "*", "ufid = '{$uid}'");
	$userfields = $db->fetch_array($query);
	$parseduserfields = array();

	// If this user is an Administrator or a Moderator then we wish to show all profile fields

$customfieldval = $parser->parse_message($userfields[$field], $parser_options);
$parseduserfields[$field] = $customfieldval;
maybe there's a problem with the view permissions of the fields? they may not be viewable on profile, or be seen by a certain usergroup.
(2020-08-22, 07:26 PM)joiSoi Wrote: [ -> ]maybe there's a problem with the view permissions of the fields? they may not be viewable on profile, or be seen by a certain usergroup.

That was it! I didn't have it turned on to view in profile.

THANK YOU SO MUCH this is going to be the best hack ever xD I've dearly missed using MyCode in the profiles Big Grin
Pages: 1 2