Title: Custom validation not working
Last modified: May 20, 2024

---

# Custom validation not working

 *  Resolved [hamami](https://wordpress.org/support/users/hamami/)
 * (@hamami)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/custom-validation-not-working-3/)
 * Hello,
 * I’ve been trying to create a custom field validation, but I’m getting a “Too 
   few arguments” error..
 * For the hook “um_custom_field_validation_{$custom_field}”
 * I tried a very basic function, just to var_dump the arguments and it really only
   sends the $key argument..
 * I saw that your do_action does have all the arguments, but on wp-includes/class-
   wp-hook.php it calls only with $key
 * I’m using WordPress 6.5.2
 * Could you please check it on your side?
 * Thank you 🙂
 * Itai
    -  This topic was modified 2 years, 1 month ago by [hamami](https://wordpress.org/support/users/hamami/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [missveronica](https://wordpress.org/support/users/missveronicatv/)
 * (@missveronicatv)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/custom-validation-not-working-3/#post-17767664)
 * [@hamami](https://wordpress.org/support/users/hamami/)
 * You have the action hook in this file
    `.../plugins/ultimate-member/includes/
   core/um-actions-form.php` line 778
 *     ```
       /**
       				 * UM hook
       				 *
       				 * @type action
       				 * @title um_custom_field_validation_{$custom}
       				 * @description Submit form validation for custom field
       				 * @input_vars
       				 * [{"var":"$key","type":"string","desc":"Field Key"},
       				 * {"var":"$field","type":"array","desc":"Field Data"},
       				 * {"var":"$args","type":"array","desc":"Form Arguments"}]
       				 * @change_log
       				 * ["Since: 2.0"]
       				 * @usage add_action( 'um_custom_field_validation_{$custom}', 'function_name', 10, 3 );
       				 * @example
       				 * <?php
       				 * add_action( 'um_custom_field_validation_{$custom}', 'my_custom_field_validation', 10, 3 );
       				 * function my_custom_field_validation( $key, $field, $args ) {
       				 *     // your code here
       				 * }
       				 * ?>
       				 */
       				do_action( "um_custom_field_validation_{$custom}", $key, $array, $submitted_data );
       ```
   
 *  Thread Starter [hamami](https://wordpress.org/support/users/hamami/)
 * (@hamami)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/custom-validation-not-working-3/#post-17767676)
 * Yes I saw that,
 * However, for some reason, the arguments don’t transfer to wp-includes/class-wp-
   hook.php, only the first one ($key)..
 * Could you try to reproduce it?
 * Thank you,
 * Itai
 *  [missveronica](https://wordpress.org/support/users/missveronicatv/)
 * (@missveronicatv)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/custom-validation-not-working-3/#post-17767711)
 * [@hamami](https://wordpress.org/support/users/hamami/)
 * It works OK for me with this coding
 *     ```
       add_action( 'um_custom_field_validation_mobile_number', 'um_custom_validate_mobile_number', 30, 3 );
       function um_custom_validate_mobile_number($key, $array, $submitted_data) {
       // write parameters to log file
       }
       ```
   
 *  Thread Starter [hamami](https://wordpress.org/support/users/hamami/)
 * (@hamami)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/custom-validation-not-working-3/#post-17770075)
 * Oh I found the problem.. it was on my end, but your snippet helped me find the
   problem..
 * Thank you 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom validation not working’ is closed to new replies.

 * ![](https://ps.w.org/ultimate-member/assets/icon-256x256.png?rev=3160947)
 * [Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin](https://wordpress.org/plugins/ultimate-member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-member/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-member/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [hamami](https://wordpress.org/support/users/hamami/)
 * Last activity: [2 years, 1 month ago](https://wordpress.org/support/topic/custom-validation-not-working-3/#post-17770075)
 * Status: resolved