MyBB Community Forums

Full Version: Hide Custom Field in UCP BUT Require On Registration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I’m trying to figure out how to hide a custom profile field in the user cup so that it cannot be edited later on. However it is required to be filled in on the registration page. 

I’ve tried setting it up to where the field is viewable by everyone, required on registration but only editable by staff. Unfortunately this means it can’t be filled in on registration and essentially stops registration. 

Is it possible for me to somehow just hide this field in the User CP only?
Friendly bump....
Have you tried:

Required: Yes

Registration: Yes

Editable: No

Profile: No

Postbit: No

Viewable by: Admin / Mods
I tried that but it stops registration because they can’t see the field that is required to be filled in
(2018-01-18, 09:33 PM)isoldehn Wrote: [ -> ]I tried that but it stops registration because they can’t see the field that is required to be filled in

Try "Editable By" part, and set it to Guests.
Oh that’s actually smart! Thanks I’ll give that a shot and see if it works.
(2018-01-18, 09:52 PM)isoldehn Wrote: [ -> ]Oh that’s actually smart! Thanks I’ll give that a shot and see if it works.

Good luck, apart from that I don't know.
This was a planned and implemented feature in 1.8.0, however it didn't work as expected and I can't remmeber if it was ever fixed.
Would it be possible to add some sort of script in the usercp.php file to have this profile field hidden?

That way on registration (member.php) it’s still visible and required, so filled in when registering but when going to edit the profile it is then hidden with said script.

I know profile fields are pulled in the usercp.php file with an exploding string.

I’ve got template conditionals installed and have tried to add it into one of the templates for profile fields similar to:
<if $customfield['fid'] = 7 then></if>
Hoping that this would then display nothing when that field came up but that didn’t work either. (member_profile_customfields_field template)
I believe you could simply add your conditional to the following line:
if(!is_member($profilefield['editableby']) || ($profilefield['postnum'] && $profilefield['postnum'] > $mybb->user['postnum']))

Something like:
if(!is_member($profilefield['editableby']) || ($profilefield['postnum'] && $profilefield['postnum'] > $mybb->user['postnum']) || (int)$profilefield['fid'] === 1)

And after:
$plugins->run_hooks("usercp_do_profile_start");

Something like this might work:
!isset($mybb->input['profile_fields'][1]) or unset();

1 is the profile field id (fid). But you will need to adapt to consider groups, moderators, and probably even the moderator control panel, from which moderators can edit fields too.