A Cozmoslabs Product
Documentation / Developer Knowledge Base / Make Last Name and First Name fields required

Make Last Name and First Name fields required

By default, the First and Last Name fields from the form are not required. In order to make them required, you need to add the following snippet of custom code to your website:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
add_filter( 'pms_register_form_label_first_name', 'pmsc_first_name_field_label');
function pmsc_first_name_field_label( $attributes ){
	return __( 'First Name *', 'paid-member-subscriptions' );
}
 
add_filter( 'pms_register_form_label_last_name', 'pmsc_last_name_field_label');
function pmsc_last_name_field_label( $attributes ){
	return __( 'Last Name *', 'paid-member-subscriptions' );
}
 
add_action( 'pms_register_form_validation', 'pmsc_first_last_validation' );
function pmsc_first_last_validation(){
	if( empty( $_POST['first_name'] ) )
		pms_errors()->add( 'first_name', __( 'This field is required.', 'paid-member-subscriptions' ) );
 
	if( empty( $_POST['last_name'] ) )
		pms_errors()->add( 'last_name', __( 'This field is required.', 'paid-member-subscriptions' ) );
}

You can download a small plugin containing this code from here. After downloading, you just need to install and activate it on your website.
The code can also be added inside the `functions.php` file from your child theme.

If you need help with any of this or have questions, don’t hesitate to contact our customer support.

The Ultimate Membership Bundle

Combine the power of Profile Builder with Paid Member Subscriptions to set up user registration, memberships, and recurring revenue.

Get 25% off with the bundle

Help & Support

We’re here to help you every step of the way.

Open a Support Ticket