Hide custom user field from registration form


(Anton) #1

Is it possible to create a custom user field that will be accessible in user profile page, but hidden in the registration form?

Use-case

in my community, there are little people and they often know each other. They’d like us, mods and admins, to be able to call them, so I’d create a phone customer field. However, I don’t want it to be displayed on the registration form, because some people might think it’s compulsory, which prevents from registration.


(Jeff Atwood) #2

No, but there is a plugin to add hidden mod notes to an account. You can ask @cpradio about it!


(cpradio) #3

Hmm, not sure if it is a good use case for that though. As the Private Notes plugin is primarily for one individual to write notes for them to see only on another account (or for staff to make notes available to other staff).

It really isn’t meant for the existing user to fill in additional detail.

I’m not sure what the best course of action would be for this. Maybe create the custom field, but then hide that field using CSS from the registration form? Can users modify a custom field via their profile later?


(Jeff Atwood) #4

Seems correct to me!


(cpradio) #5

Well, yes, in that admins/staff can then call them if the data is there, but consider the use

  1. User A enters a private note with their phone number
  2. Staff/Mods can’t see private note, as the note is for view only by User A

To get around this

  1. User A tells staff my phone number is X
  2. Staff enter user note on User A with the phone number
  3. All staff can see the phone number.

So I still think it isn’t ideal, however, you might be able to fork the plugin enough to make it do what you really want.


(Anton) #6

The intention is to let users fill in their details.

Why not just add another boolean flag to custom fields: show on registration page.


(cpradio) #7

You can probably hide it using CSS from the registration page, that should solve your immediate concern, right?


(Stephanie) #8

Would putting (Optional) next to that field not be enough to assure people it’s not mandatory?


(Anton) #9

Yes, sure, it’s a good workaround.
I’m just proposing the way to improve it eventually.


(Anton) #10

No, it would not. I want as few inputs as possible on my registration form.


(Anton) #11

One more use-case for this feature

In our case, at forum.kozovod.com, we have personal topics (aka personal pages) which every goat farmer creates. It is used as a newsfeed of their own farm only.

Some users have been asking for a “personal topic” field visible in profiles of everyone, so that they’re easy to find and switch to quickly. However, there is no sense showing the corresponding input in the signup form.

I haven’t found any way in the admin panel to not show the field in the registration form, hence proposing a new checkbox in the admin area: “show in the signup form”.


(Anton) #12

There is no unique ID for that. Any ideas how I would achieve this?


(Mittineague) #13

CSS doesn’t always need an element to have a unique id (though it can make things easier)
What is needed is the proper selector(s) eg. (using the dev tools inspector)

<div style="display: block; padding-right: 0px;" data-keyboard="false" class="ember-view modal hidden create-account in" id="discourse-modal">
....
  <div class="modal-body">
....
      <div>
        <form>
....
          <div class='user-fields'>
            {{#each f in userFields}}
              {{user-field field=f.field value=f.value}}
            {{/each}}
          </div>

so something like this

#discourse-modal.create-account div.modal-body div.user-fields { 
  display: none;
}

should hide all user fields in the create account modal.

If you need some and not others, use your browsers dev tools inspector to determine the child node selector(s) of interest.


(Anton) #14

That’s my case. Which child node selector(s) should I attempt using? Do you mean nth child etc?


(Mittineague) #15

If they don’t have any id or class you can use to target them, then yes, nth child is probably the best if not the only way to target the individual child nodes


An option for user field to be hidden in sign up
Hiding User Fields on signup without deleting them
(Christoph) #16

Is the CSS workaround the final solution for hiding custom user fields on the registration form or will there be something lika a “show on registration form” - flag?