Custom form validation ?

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Viewing 2 reply threads
  • Author
    Posts
    • #21301
      Connor
      Guest

      Hi,

      At the moment it only seems to *REQUIRE a title to add a product.

      All custom fields added via the WCFM settings can be make required instead of optional.

      Is there a way to make other fields required such as a category, short description etc?

    • #21333
      WCFM Forum
      Keymaster

      Hi,

      Yes you may definitely do this.

      Here is a sample code for you. It set shipping fields required –

      function wcfm_custom_product_manage_fields_shipping( $shipping_fields, $product_id ) {
      	global $WCFM;
      	if( isset( $shipping_fields['weight'] ) ) {
      		$shipping_fields['weight']['custom_attributes'] = array( 'required' => 1 );
      	}
      	if( isset( $shipping_fields['length'] ) ) {
      		$shipping_fields['length']['custom_attributes'] = array( 'required' => 1 );
      	}
      	if( isset( $shipping_fields['width'] ) ) {
      		$shipping_fields['width']['custom_attributes'] = array( 'required' => 1 );
      	}
      	if( isset( $shipping_fields['height'] ) ) {
      		$shipping_fields['height']['custom_attributes'] = array( 'required' => 1 );
      	}
      	if( isset( $shipping_fields['shipping_class'] ) ) {
      		$shipping_fields['shipping_class']['custom_attributes'] = array( 'required' => 1 );
      	}
      	return $shipping_fields;
      }
      add_filter( 'wcfm_product_manage_fields_shipping', 'wcfm_custom_product_manage_fields_shipping', 50, 2 );

      Hope this will help full for you to do the same for others.

      Thank You

    • #21724
      WCFM Forum
      Keymaster

      Hi,

      You don’t need to use this code any more.

      You are now allowed to set such validation from WCfM Admin Settings -> Product Custom Validation

      Thank You

Viewing 2 reply threads
  • The topic ‘Custom form validation ?’ is closed to new replies.