ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Any way to make an optional registration field mandatory?

July 21, 2008 1:12pm

Subscribe [4]
  • #1 / Jul 21, 2008 1:12pm

    DarkScythe

    36 posts

    Hello,

    I’m wondering if there is a way to make the ‘birthday’ field mandatory on user registration.
    I don’t need to make it public or anything, but it seems the only way to set the birthday is going to the profile.
    I’m looking to see if I can make it so that users must include their birthday when registering, and disallow them from changing it afterwards.
    The reason is because I’m going to use this information to exclude certain categories from view for certain age groups, which should be doable with some conditionals.
    This is not foolproof, but no method really is if the person is determined to get at the content, so I just need something simple.

    Thanks in advance.

  • #2 / Jul 21, 2008 6:06pm

    Ingmar

    29245 posts

    You can create custom profile fields (and make them required, too), but no easy way to modify the existing fields. Also, your other requirements (not being able to change afterwards) might be a bit more difficult to achieve. I imagine some custom coding should be able to do it, but there is no out of the box functionalit for this.

    Moving to Howto.

  • #3 / Jul 22, 2008 12:42am

    DarkScythe

    36 posts

    lol, took me a while to find this thread again.

    Thanks for the reply - I know I can create a custom profile field, but wouldn’t that conflict with the birthday field already built in?
    If not, could I do it this way: Make a custom profile field called birthday or something and make it mandatory, then take those values and input them into the table where the user birthday normally would be, then perhaps modify the member profile template to remove access to changing that value?

  • #4 / Jul 24, 2008 2:17pm

    DarkScythe

    36 posts

    Okay, nevermind the original question..
    I decided to take a look at the list of EE addons, and there’s a really old extension that still works and does exactly what I needed it to do - add the birthday field to the registration page and make it mandatory.
    I’ve also removed the ability to change the birthday from the member profile page by removing the table cell from the Member Profile Form template. It seems the admin still has access to changing it which is good.

    The last thing is that, since this is normally an optional field, I want to give users a choice as to whether they want to display it publicly or not. Going to the public profile, it is displayed by default, with no options to turn it off. I don’t want to completely remove that field though, in case they DO want to display it. In the Public Member Profile template, right above the birthday field is an IF conditional for displaying forum statistics. This seems like a good idea if I can manage it for the birthday field. Could I create a custom member profile field for the user to select yes/no and use the result of that as the conditional to display/hide the birthday field?

    Thanks

    Edit:
    Dangit, I keep running into problems.

    I successfully made a custom profile field to run a conditional IF against to see whether or not to display the birthday in the public profile - this works.
    However, I overlooked the fact that when the user goes to change this option in the profile, it would try to look up whether they changed their birthday as well, which results in it not finding anything since I removed that field from the profile page, and thus updates the database with 0’s.. I’m trying to find a way to work around this now - to prevent the birthday from changing.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases