MyBB Community Forums

Full Version: Separating Custom Fields into Sections
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(2019-02-21, 09:22 PM)dragonexpert Wrote: [ -> ]Let's not start a fight in this thread.

@Ersatz, have you ever thought about using a separate page for profile information related to a game or whatever that information is for?  I'd suggest doing that and having a link to that.  This way you keep forum stuff with the forum profile and nonforum profile info on a separate page.

Sure I've thought of it, but telling users that 90% of their settings are in X and 10% are in Y seems both inelegant and unintuitive. Factor in that usercp.php is also doing the bulk of the work and just needs a bit to tweak, it would also be a lot of work reinventing the wheel.

Frankly, I'm a little surprised no one has added categories to custom fields. Blasting them all out in new rows in a single table is just... really inflexible.

But it doesn't really matter since this was really about parsing out the $pfcache. Given that at least three people had asked about it before me and one current active member just expressed interest, it's not as if I'm off on an island. Kind of a shame it's been years for someone to bother to actually find the solution.

Cutting them up into sections and having USERCP.PHP build out the sections was even easier than I thought it would be.

Find:

if($profilefield['required'] == 1)
     {
     eval("\$requiredfields .= \"".$templates->get("usercp_profile_customfield")."\";");
     }
else
     {
     eval("\$customfields .= \"".$templates->get("usercp_profile_customfield")."\";");
     }

$altbg = alt_trow();
$code = "";
$select = "";
$val = "";
$options = "";
$expoptions = "";
$useropts = "";
$seloptions = array();
}
}
}

Change to:
if($profilefield['required'] == 1)
     {
         eval("\$requiredfields .= \"".$templates->get("usercp_profile_customfield")."\";");
     }
else
     {
$mycustomfieldsgroup1array = array(4,564,565);

if (in_array($profilefield['fid'],$mycustomfieldsgroup1array)) {
eval("\$mycustomfieldsgroup1 .= \"".$templates->get("usercp_profile_customfield")."\";");
} else { 
eval("\$customfields .= \"".$templates->get("usercp_profile_customfield")."\";");
}
}

$altbg = alt_trow();
$code = "";
$select = "";
$val = "";
$options = "";
$expoptions = "";
$useropts = "";
$seloptions = array();
}
}
}

$mycustomfieldsgroup1array is the FIDs of the custom fields you want to remove from the main group

$mycustomfieldsgroup1 is what you insert into the template as {$mycustomfieldsgroup1} to display the group you just made.

Repeat the array, else, and eval statements to create multiple groups of customs to display as desired.



UserCP customfields in categories with collapses:

[attachment=41573]
Pages: 1 2