WordPress.org

Forums

Advanced Custom Fields: Validated Field
[resolved] Can not pass any validation (8 posts)

  1. ikivanov
    Member
    Posted 1 year ago #

    I am trying for create a validated custom field containing only numbers. (phone number). I tried any possible combination and can't pass the validation check.
    I tried with and without server side validation, even Required/Not-required field

    See some screen shots here.
    http://we.tl/ESBp6oqra4

    Thanks in advance for your help.

    https://wordpress.org/plugins/validated-field-for-acf/

  2. doublesharp
    Member
    Plugin Author

    Posted 1 year ago #

    @ ikivanov I am not able to see your screenshots, it looks like the link has expired. Can you please provide them again as well as let me know what version of WordPress and ACF you are using? If you could take a look at your console as well and let me know if there are any javascript errors.

    Thanks!

  3. ikivanov
    Member
    Posted 1 year ago #

    http://we.tl/9fmEAklIVi

    Here is the link again. I did screenshots of the field setup and the message with console log.
    No JS errors.

    What I am trying to do is to change one ACF text field to validated text field which will accept only numbers for a phone number. Then it should be unique for a custom post type.

    Let me know if I can help with providing more info.
    Thanks for your plugin and support.
    The link last 7 days.

  4. doublesharp
    Member
    Plugin Author

    Posted 1 year ago #

    @ikivanov - thanks, I was able to reproduce the error and found some bad SQL when checking for unique values per post_type. It has been corrected and I just pushed out a new version of the plugin. 1.0.3.

    Thanks!

  5. ikivanov
    Member
    Posted 1 year ago #

    Thanks, I will check it in a couple of days and will let you know if it worked.

  6. ikivanov
    Member
    Posted 1 year ago #

    Just updated the plugin and got this after I tried to update a post

    Notice: Undefined index: value in .../plugins/validated-field-for-acf/validated_field_v4.php on line 45

    Notice: Undefined index: value in .../plugins/validated-field-for-acf/validated_field_v4.php on line 45

    Warning: Cannot modify header information - headers already sent by (output started at .../plugins/validated-field-for-acf/validated_field_v4.php:45) in .../wp-admin/post.php on line 233

    Warning: Cannot modify header information - headers already sent by (output started at .../plugins/validated-field-for-acf/validated_field_v4.php:45) in .../wp-includes/pluggable.php on line 896

    However, it saved the value.
    Then I tried with a value which won't pass. It showed the error but then even if I key a correct value it acts the same as before.

  7. ikivanov
    Member
    Posted 1 year ago #

    Also,
    if I update the post it will throw an error. Does the edited post is excluded from the check for unique field value?

  8. doublesharp
    Member
    Plugin Author

    Posted 1 year ago #

    I just pushed version 1.0.4 which includes a fix for the PHP notices as well as a Javascript error.

    The plugin does exclude the current post from the check. Once you upgrade to the latest version if you are still having an issue please open a new thread with the details so I can follow up (the issue on this should now be resolved). If you want to check out the source code, the unique checks begin here https://plugins.trac.wordpress.org/browser/validated-field-for-acf/tags/1.0.4/validated_field_v4.php#L124 and the SQL for the post_type check is here https://plugins.trac.wordpress.org/browser/validated-field-for-acf/tags/1.0.4/validated_field_v4.php#L131

    SQL prefix

    $sql_prefix = "select meta_id, post_id, p.post_title from {$wpdb->postmeta} pm join {$wpdb->posts} p on p.ID = pm.post_id and p.post_status = 'publish'";

    post_type SQL

    case 'post_type':
        // check to see if this value exists in the postmeta table with this $post_id
        $sql = $wpdb->prepare("{$sql_prefix} and p.post_type = %s where post_id != %d and meta_value = %s", $post_type, $post_id, $val);
        break;

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields: Validated Field
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic