Support

Account

Forum Replies Created

  • Just an update for @beh333. I actually never resolved this issue with the filter. I needed up simply using a server side jQuery limiter and validation to work around the problem.

  • Ok, sorry this project went dead for a while, but I’m back at it and still having the same issue. I tried disabling all plug-ins except ACF and changing the template, but I’m still having the same problem. I don’t know if it will help, but this is my add_filter code:

    function fe_profile_validate_about_me( $valid, $value, $field, $input ) {
        
        //only run in on profiles
        if( is_admin()  || ! get_post_type() == 'profiles' )
        {
            return $valid;
        }
    
        $cleaned_value = wp_strip_all_tags( $value );
    
        if( strlen( $cleaned_value ) > 515 ) {
            $valid = '<div style="text-align: center"><h3>Unable to update your profile</h3>
            <p>We were unable to update your profile because your "About Me" was longer than 515 characters.</p>
            <p><a href="javascript:void(0);" onclick="window.location.reload(true);" class="button">Back to profile</a></p></div>';
        }
    
        return $valid;
    }
    add_filter('acf/validate_value/name=fe-profile-short-description', 'fe_profile_validate_about_me', 10, 4);
  • This code is great, but I also need to handle some custom validation and errors. So my questions are:

    1) How do you handle and display any validation errors?

    2) How can I add in custom validation?

    I was doing this with a add_filter('acf/validate_value/) call, but with the AJAX submit on the form when this fails it seems to just halt the ajax (keeps spinning forever).

    I’m guessing the solution has something to do with moving my code to the acf.add_filter('validation_complete') JS filter, but any guidance would be appreciated. Thanks!

  • What about escaping the output for security? I assume since you need the “raw” code on output you cannot use the esc_html or esc_js functions, but does that pose a possible security risk?

  • That has been my experience as well. So what I’m wondering now is, is this a bug or intended functionality? Since, as you said, it’s like a Repeater and the check seems to be have_rows no rows in a Repeater is false yet here with a Group evaluates to true. I would argue it’s a bug.

  • Thanks @charleslf, but I’m a bit confused by the GitHub threads. So was the fix not rolled into the 0.9.5.4 update? That seems to be what is being indicated here if I’m reading this right.

  • We seem to be hitting this issue on our site where we just enabled W3TC last week. In our case we are using a save_post hook on a custom post type and have it set to run at the default priority of 10. After turning on W3TC the values of our get_field calls in the save_post running in the admin are all returning blank. Oddly we tried totally disabling the W3TC plugin and purging all it’s cache, but the issue persists. Using the ‘Debug Objects’ plug-in we still see the W3TC cache objects even with the plug-in disabled and with repeatedly purging the cache. We also tried leaving the W3TC plugin active and disabling and punching it’s object cache and that did not help.

    We have also tried adjusting the priority on the save_post call to 999 and that did not help. Oddly moving the priority to earlier, 9, did fix the get_field issue, but then when we tried later to call update_field that failed to save the data to the wp_postmeta table.

    At this point we are at a bit of a loss on how to proceed with troubleshooting and debugging this issue. Any thoughts or help would be appreciated.

  • Thanks I really appreciate the responses and help. I will start digging and if I discover anything report back here.

  • Let me try to answer these:

    1) Yes.

    2) Yes

    3) Yes

    4) No.

  • I actually have WP_DEBUG on and I’m not getting any error in the browser or in the PHP error logs. As I mentioned I’m using acf_form so this is a front-end form. Does that make any difference? What is being returned is a fully formed HTML response:

    <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"><head>
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    	<meta name="viewport" content="width=device-width">
    	<meta name="robots" content="noindex,follow">
    	<title>Validation failed</title>
    	<style type="text/css">
    		html {
    			background: #f1f1f1;
    		}
    		body {
    			background: #fff;
    			color: #444;
    			font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    			margin: 2em auto;
    			padding: 1em 2em;
    			max-width: 700px;
    			-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.13);
    			box-shadow: 0 1px 3px rgba(0,0,0,0.13);
    		}
    		h1 {
    			border-bottom: 1px solid #dadada;
    			clear: both;
    			color: #666;
    			font-size: 24px;
    			margin: 30px 0 0 0;
    			padding: 0;
    			padding-bottom: 7px;
    		}
    		#error-page {
    			margin-top: 50px;
    		}
    		#error-page p {
    			font-size: 14px;
    			line-height: 1.5;
    			margin: 25px 0 20px;
    		}
    		#error-page code {
    			font-family: Consolas, Monaco, monospace;
    		}
    		ul li {
    			margin-bottom: 10px;
    			font-size: 14px ;
    		}
    		a {
    			color: #0073aa;
    		}
    		a:hover,
    		a:active {
    			color: #00a0d2;
    		}
    		a:focus {
    			color: #124964;
    		    -webkit-box-shadow:
    		    	0 0 0 1px #5b9dd9,
    				0 0 2px 1px rgba(30, 140, 190, .8);
    		    box-shadow:
    		    	0 0 0 1px #5b9dd9,
    				0 0 2px 1px rgba(30, 140, 190, .8);
    			outline: none;
    		}
    		.button {
    			background: #f7f7f7;
    			border: 1px solid #ccc;
    			color: #555;
    			display: inline-block;
    			text-decoration: none;
    			font-size: 13px;
    			line-height: 26px;
    			height: 28px;
    			margin: 0;
    			padding: 0 10px 1px;
    			cursor: pointer;
    			-webkit-border-radius: 3px;
    			-webkit-appearance: none;
    			border-radius: 3px;
    			white-space: nowrap;
    			-webkit-box-sizing: border-box;
    			-moz-box-sizing:    border-box;
    			box-sizing:         border-box;
    
    			-webkit-box-shadow: 0 1px 0 #ccc;
    			box-shadow: 0 1px 0 #ccc;
    		 	vertical-align: top;
    		}
    
    		.button.button-large {
    			height: 30px;
    			line-height: 28px;
    			padding: 0 12px 2px;
    		}
    
    		.button:hover,
    		.button:focus {
    			background: #fafafa;
    			border-color: #999;
    			color: #23282d;
    		}
    
    		.button:focus  {
    			border-color: #5b9dd9;
    			-webkit-box-shadow: 0 0 3px rgba( 0, 115, 170, .8 );
    			box-shadow: 0 0 3px rgba( 0, 115, 170, .8 );
    			outline: none;
    		}
    
    		.button:active {
    			background: #eee;
    			border-color: #999;
    		 	-webkit-box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 );
    		 	box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 );
    		 	-webkit-transform: translateY(1px);
    		 	-ms-transform: translateY(1px);
    		 	transform: translateY(1px);
    		}
    
    			</style>
    </head>
    <body id="error-page">
    	<p></p><h2>Validation failed</h2><ul><li><div style="text-align: center"><h3>Unable to update your profile</h3>
            <p>We were unable to update your profile because your "About Me" was longer than 515 characters.</p>
            <p><a href="javascript:void(0);" onclick="window.location.reload(true);" class="button">Back to profile</a></p></div></li></ul><p></p>
    
    </body></html>
  • I’m having a bit different issue with this filter. My validation is working, but I’m using this with a front end acf_form and when the validation error triggers it’s displaying the message on the full page and not as a error on the field. Is that expected? I am using this on a WYSIWYG field if that makes any difference.

  • Hey @hube2 I have a similar need but I only want to limit the character length when using an acf_form on the front end. Is it possible with the plug-in to set the character limit dynamically from a hook/filter?

  • Ok. They confirmed that there is some conflict and are looking into it, but also said that the wc_modify_editable_roles fix should work. Let me try again and I’ll update here.

  • FYI, we just upgraded to WooCommerce 3.0 and it did NOT resolve this issue. Should I report this issue to them as a “bug/conflict”?

    Update: Sorry just saw that you said in your last post that I should talk to WC.

    I can also verify that adding the filter on the wc_modify_editable_roles did not fix the issue for me so it must be some other filter. I’ve filed a bug with Woo Commerce here: https://github.com/woocommerce/woocommerce/issues/14580

    Update 2: The above filter code DID work

  • Thanks a lot John. I appreciate you taking the time to point me in the right direction.

  • Sorry it took me longer to get back to you on this than expected. After doing extensive testing there does seem to be a plug-in conflict with WooCommerce 2.6.14. WooCommerce 3.0 came out last week, but it will be a while before I’ll be able to upgrade and test. Being a major upgrade to Woo we need to vet our theme and other plug-ins. We’re working on other stuff at the moment, so it might be a week or two before we do that.

    I have also not dug into the code to see why 2.6.14 is causing this problem with ACF either. If you have any ideas I’d appreciate your thoughts.

  • I am in the process of needing to do something very similar to this. Did this end up working for you @jeffthefish?

  • Was there ever any resolution to this? I’m trying to track down an issue I seem to be having a possibly similar issue with ACF Form and using it from the front-end to add images to a post or post gallery.

    What’s working:
    I can create my form and use it with the uploader to add images to the media library which also get attached to the correct post (records created in wp_postmeta).

    What’s not working:
    When I look at the custom post type record in the admin the images are not associated with their ACF field. Looking in the database I can see there are no act records for the image or gallery fields in wp_postmeta

  • OK. Never mind, right after I posted this I found the “Insert” setting with the “Prepend to the Beginning” option in the Gallery field settings. I’m an idiot. You can ignore this post since I did not find a way to delete it. Sorry.

  • I tried the plugin and it is not working for me at all. I see the settings in ACF and have enabled the “quick edit” option for the field I want to appear, but nothing shows up in the quick edit view for me.

  • Hey, I have a project where I’m thinking of using a front end ACF form and security is a primary concern. I’m following this thread and curious how close you are to implementing this new security in an update? Basically should I wait of the fix or implement one of the recommended work arounds?

  • Thanks, this information is helpful. So just to be clear the order returned for post objects is the order they are in the relationship field (I assume from top to bottom?). This is what I think WordPress calls “menu_order” is that correct? If that’s so, in my case this will work for my scenario.

  • So I want to do something similar to this and I understand the solution of returning the IDs and using a WP_Query to get only the ones I want. Obviously that creates an extra DB call, so my question is one of performance. Is it better to return the IDs and do the extra WP_Query or would it work to just use PHP to limit the array result after the fact with PHP? Maybe using array_slice For example:

    
    $posts = get_field('conference_talks');
    $posts= array_slice($posts, 0, 5);
    
Viewing 23 posts - 1 through 23 (of 23 total)