• Resolved hamami

    (@hamami)


    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 9 months, 2 weeks ago by hamami.
Viewing 4 replies - 1 through 4 (of 4 total)
  • @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

    (@hamami)

    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

    @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

    (@hamami)

    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.