Support

Account

Forum Replies Created

  • Hi,

    Has there been any update on this issue?
    It seems it’s still not possible to set a datetime field to read only.

    Trying to find a workaround based on John’s suggestions.

  • I had looked everywhere… except in wp-config.php !

    There was indeed a date_default_timezone_set() there.

    Thanks a lot !

  • Is this really solved for everybody ? I’m still getting the issue with only ACF as activated plugin. I noticed the problem happens when I use the classic WP editor, but not when I use Gutenberg.

  • Hi,

    This code works, but it counts the number of total HTML characters in the field, not the rendered number of characters (what the user sees in the visual editor).

    For example, if you type the text « Hello World », it will count 11 characters. But if you put this same text in bold, it will count 28 characters, because the content of the field is actually : <strong>Hello World</strong>.

    So a better solution would be to strip the tags from the value variable before counting the number of characters, like so :

    add_filter('acf/validate_value/name=wysiwyg_field_name', 'my_acf_validate_value', 10, 4);
    
    function my_acf_validate_value( $valid, $value, $field, $input ){
        
        // bail early if value is already invalid
        if( !$valid ) {
            
            return $valid;
            
        }
        
        if( strlen(strip_tags($value)) > 40 ) {
            
            $valid = 'You can\'t enter more that 40 chars';
            
        }
        
        
        // return
        return $valid;
        
        
    }
  • Hi @bc_andre,

    I’m having the same issue, did you find a solution ?

    Thanks

Viewing 5 posts - 1 through 5 (of 5 total)