MyBB Community Forums

Full Version: Custom profile fields in post bit
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is it possible to add the custom profile fields to the posts? If not, it should be Toungue
Thanks for the great software, a nice break from my old bugged copy of Invision.
When you've created the custom profile field in the Admin CP, you can place this variable in your postbit template:
$post[fidX]
You have to replace X with the field ID which you can find in the Admin CP Custom Profile Field management page.

Please note that these custom profile fields are not htmlspecialchar'ed, which means any HTML that is entered in by the user will be rendered as HTML from the browser.
Thank you so much!
Is there any way to make it have it, so if they filled out the custom field then it shows it, along with the title next to it. And if they have not filled it out there is nothing.

For example, lets say the special field is favourite color.

If the person has specified a favourite color of red, on the postbit it would show

Favourite Color: Green

If they have not filled it out, nothing shows up, not even the favourite color: part.
^^

I have been fiddling around, but I do not really know php very well. So does anyone know how to do this? If you do not understand what I am talking about just say and I will try to explain it more.
Hey,

open ./inc/function_post.php

find

if($post['avatar'] != "" && $mybb->user['showavatars'] != "no")

above it add


    $fidc = $db->fetch_array($db->query("SELECT fid4 FROM ".TABLE_PREFIX."userfields WHERE ufid='$post[uid]'"));
        if($fidc[fid4] != ""){
            $fidc = "The color is: ".$post[fid4]."<br />";
        } else {
			$fidc = "";
		}


replace fid4 by fidX ( where x is the ID# for that field in your settings Smile

Now in the postbit template just add $fidc

regards
Thanks! Works fantastic!
zaher1988 Wrote:Hey,

open ./inc/function_post.php

find

if($post['avatar'] != "" && $mybb->user['showavatars'] != "no")

above it add


    $fidc = $db->fetch_array($db->query("SELECT fid4 FROM ".TABLE_PREFIX."userfields WHERE ufid='$post[uid]'"));
        if($fidc[fid4] != ""){
            $fidc = "The color is: ".$post[fid4]."<br />";
        } else {
			$fidc = "";
		}


replace fid4 by fidX ( where x is the ID# for that field in your settings Smile

Now in the postbit template just add $fidc

regards

For safety reasons instead of:
            $fidc = "The color is: ".$post[fid4]."<br />";
you should use
            $fidc = "The color is: ".htmlspecialchars_uni($post[fid4])."<br />";