I need to make the screen_name input field on my CP Register Member form required.

Here is what I currently have:

// Screen Name
    form_label(required().lang('Client Name'), 'screen_name').NBS.form_error('screen_name'),
        'id'    => 'screen_name',
        'name'  => 'screen_name',
        'class' => 'field',
        'maxlength' => 50,
        'value' => set_value('screen_name')

I am not sure what else I need to do to make this a required field. Thanks!

  • Please provide more information about what specifically in your code isn't working...
    – Anna_MediaGirl
    Nov 19, 2013 at 16:06

1 Answer 1


Assuming this is a custom add-on you are building, you need to use the ExpressionEngine form validation class to truly make it required.

There is even a method specifically for screen name.

ee()->form_validation->set_rules('screen_name', 'Screen Name', 'required|valid_screen_name');

See valid_screen_name

There are other rules you can use, too. Check the form validation class Rule Reference in the CodeIgniter docs.


Since you're referring to the Control Panel's Members > Register Member form...

Unless you find or build an extension to do this for you, you actually have to make a tiny modification to the core to make this happen.

The following is based on EE 2.7.2, but should be similar for older versions.

Make the modification in /system/expressionengine/controllers/cp/members.php. Around line 2170 inside the new_member_form() method you just need to add a "required" rule to the validation on the "screen_name" field.

So the rules for screen_name should look like this:

'rules' => 'required|trim|valid_screen_name[new]'
  • Thank you so much for your feedback. I actually am just trying to set this up within the views > members > register.php file. I also have been trying to figure out the Libraries > Validate.php screen_name validation but I am not sure confident with either. Where would I apply that class?
    – prosborne
    Nov 20, 2013 at 5:04
  • Ah, I see. I updated my answer. What version of EE are you using?
    – Alex Kendrick
    Nov 20, 2013 at 15:15
  • I am using 2.7.2 so that worked perfectly. Thanks again!
    – prosborne
    Nov 21, 2013 at 5:11
  • 1
    tip: and write it down inside a changes.txt so you know what files you need to edit after upgrading to the next EE version.
    – GDmac
    Nov 21, 2013 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.