• Resolved kimkuhlman

    (@kimkuhlman)


    I’d like to make the city and state fields required when vendors sign up because they don’t always autopopulate. How can I accomplish that? I’ve added a snippet from the first and last names found elsewhere, but the red asterisk doesn’t come up. Can these fields be added to the “Registration Form Fields” under “Membership General Options?” TIA!

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author WC Lovers

    (@wclovers)

    Hi,

    Use this snippet for first and last name –

    add_filter( 'wcfm_membership_registration_fields', function( $registration_fields ) {
    	if( isset( $registration_fields['first_name'] ) ) {
    		$registration_fields['first_name']['custom_attributes'] = array( 'required' => 1 );
    	}
    	if( isset( $registration_fields['last_name'] ) ) {
    		$registration_fields['last_name']['custom_attributes'] = array( 'required' => 1 );
    	}
    	return $registration_fields;
    }, 50 );

    and this snippet for city and state –

    add_filter( 'wcfm_membership_registration_fields_address', function( $address_fields ) {
    	if( isset( $address_fields['city'] ) ) { 
    	  $address_fields['city']['custom_attributes'] = array( 'required' => 1 );
    	}
    	if( isset( $address_fields['state'] ) ) { 
    	  $address_fields['state']['custom_attributes'] = array( 'required' => 1 );
    	}
    	return $address_fields;
    }, 50 );

    Add custom code(s) to your child theme’s functions.php
    In case you do not have child theme then add those using this plugin –?https://www.ads-software.com/plugins/code-snippets/

    Thank You

    Thread Starter kimkuhlman

    (@kimkuhlman)

    Thanks for your reply and the second snippet. Is there a way to add the red asterisk after the city and state fields?

    Plugin Author WC Lovers

    (@wclovers)

    Hi,

    Do you have added my “city and state” code?

    It will red asterisk as well. Like this – https://ibb.co/ThXhZ4f

    Thank You

    Thread Starter kimkuhlman

    (@kimkuhlman)

    I discovered I had an extra space in my snippet comment ??. Works just fine now. Thanks so much!

    Plugin Author WC Lovers

    (@wclovers)

    Ahh .. thanks for the update ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Help making city and state fields required for membership’ is closed to new replies.