I have a field that echos the iframe code entered by users having role “Business Owner”.
These users have limited capabilities and can only save, update posts of a custom post type called “”Business Owner Posts”. My ACF fields are visible in such post types only.
I have noticed that when such users enter the iframe code and try to save it does not get accepted – the field returns empty.
But the same does not happen when it is entered by users having admin privileges.
Now, I understand there are security concerns when it comes to iframes but I am sanitizing the entered iframe with regex to ensure they only come from a certain URL and none other.
So how do I make ACF accept the iframe code as entered by the user type?
I’m having issues adding checkbox fields with hard-coded choices (in admin).
Every time I add a checkbox and adding the choices in admin, I’m getting this error:
array_map(): Argument #2 ($array) must be of type array, int given
Checkboxes added using taxonomy field are fine.
In:
/advanced-custom-fields-pro/includes/fields/class-acf-field-checkbox.php:247
This is the code:
$args[‘disabled’] = array_map( ‘esc_attr’, $args[‘disabled’] );
($args[‘disabled’] is 0)
Here’s the field.:
{
“key”: “field_65e14ce0816cf”,
“label”: “Charts Reporting To”,
“name”: “charts_reporting_to”,
“aria-label”: “”,
“type”: “checkbox”,
“instructions”: “”,
“required”: 0,
“conditional_logic”: 0,
“wrapper”: {
“width”: “”,
“class”: “”,
“id”: “”
},
“disabled”: 0,
“relevanssi_exclude”: 0,
“choices”: {
“Country Aircheck”: “Country Aircheck”,
“Music Row”: “Music Row”,
“AMA”: “AMA”,
“Roots Music Report”: “Roots Music Report”,
“Bluegrass Unlimited Survey”: “Bluegrass Unlimited Survey”,
“Bluegrass Today Bluegrass”: “Bluegrass Today Bluegrass”,
“Bluegrass Today Grassicana”: “Bluegrass Today Grassicana”,
“Bluegrass Today Gospel”: “Bluegrass Today Gospel”,
“Singing News”: “Singing News”,
“Singing News Bluegrass”: “Singing News Bluegrass”
},
“default_value”: [],
“return_format”: “value”,
“allow_custom”: 1,
“save_custom”: 0,
“layout”: “vertical”,
“toggle”: 0,
“custom_choice_button_text”: “Add new choice”
},
I noticed all ACF fields have disabled set to zero.
Any help is appreciated.
Hello,
As i just figured out, when using the new feature to save block meta in the postmeta table, the block is limited to single use only (per page/post), even if you add the support attribute “multiple”: true.
This behaviour should be documented on this page: https://www.advancedcustomfields.com/resources/save-acf-block-values-to-post-meta/
Thanks!
Hi,
I am currently working on a few small utility applications to help move data from locally stored files to a locally hosted WordPress site. I am doing this through python-xmlrpc which has worked well up until this point.
I would like to pre-face this by saying that I do not have access to change any of the theme code or the ACF field settings within the site. I can simply create and edit posts.
The issue occurs from a post type that only really makes use of the ACF fields given to it and acts like an account database for users (which are separate to the actual WordPress users). When I attempt to create a new post of this post type, it will create a new post and the fields will end up filled but not actually saved to the database. I then need to press the “Update” or “Publish” button manually on the page which will save the data and allow it to be used (since the data acts as accounts, I have tested this by trying to log into the newly made account both before and after manually “saving” the data).
I am placing the values into the WordPressPost.custom_fields attribute (https://python-wordpress-xmlrpc.readthedocs.io/en/latest/ref/wordpress.html). To do this, I am using the field name rather than the field key which is mentioned in a few other threads. I tried to use the field key to make this work but it would make the post and not actually fill in any data at all.
Does anyone know why the post will not save just from the xmlrpc call and anyways that you can make that happen?
I understand that this could just be a limitation of ACF and XMLRPC in which case I have a couple options. One to use Selenium to just simulate the button press but this would be a much slower solution. Another thought I’ve had is to try and perform the same actions that the “Update” button does but externally through my own program. The only thing I’ve found so far is a call to admin-ajax.php, so if anyone has an idea of how that could be replicated that would be very much appreciated.
I would also like to add that editing posts of this type works perfectly as expected and can even edit the new posts before I have manually pressed “Update”. Although, the new posts will not function as accounts until I have pressed “Update” even after editing through xmlrpc.
I’m building an AJAX filtering system and am trying to include a filter that can take multiple IDs and then filter custom post type posts based on its relationship field. Is there any handy method of doing meta_query with an array of values for a relationship field which is saved as array? I’m trying to achieve something like this
‘meta_query’ => array(
array(
‘key’ => ‘relationship_field’,
‘value’ => serialize([1234, 4321]),
‘compare’ => ‘LIKE’,
)
)
Is anything like this doable or is doing multiple OR conditioned meta queries the only option? This probably gets pretty heavy very quickly, so is there best practice on how many you should use, meaning I could probably limit how many IDs can be passed to the filtering function?
It’s possible to filter out posts that don’t match inside the loop with array_intersect IF statement, but that wouldn’t be very good for pagination.
i have a repeater field , when the post have more that 106 rows i get 404 when trying to save… before i could save more that 100 rows (they have only a few filds inside)
when i run phpinfo i can see:
local. master
max_execution_time 10000 10000
max_file_uploads 20 20
max_input_nesting_level 256 64
max_input_time -1 -1
max_input_vars 20000 10000
memory_limit 1G 1G
i think i change this to this high values… what could it be ? i also tryed :
/**
* Increase ACF Repeater row limit
*/
function my_acf_repeater_settings( $field ) {
$field[‘max’] = 5000; // Change this value to your desired limit
return $field;
}
add_filter(‘acf/fields/repeater/settings’, ‘my_acf_repeater_settings’);
no luck .. my acf is Ver5.12.3 … can any kind soul help me? tanks
We have a page where we use a lot of different ACF custom blocks / fields, including ACF wrappers.
When we click to update this page, the whole website goes down until its fully saved – which takes half a minute to couple of minutes.
While the update-button is loading and I go to console on the edit page it will show:
VM2831:1 GET urlremoved/wp-admin/post.php?post=169&action=edit&message=4 500 (Internal Server Error)
And if I open new window to see the website during this loading, it will show Database not connected. Sometimes 504 Gateway Time-out.
The error logs say:
PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /var/www/urlremoved/wordpress/wp-includes/wp-db.php on line 1753
Im not sure what to do to not have this happen, we tried increasing some php settings but that didnt help.
Server:
File uploads Enabled
Max size of post data allowed 13M
Max size of an uploaded file 256M
Max effective file size 13 MB
Max number of files allowed 20
Server architecture Linux 5.4.0-89-generic x86_64
Web server nginx/1.18.0
PHP version 7.4.3 (Supports 64bit values)
PHP SAPI fpm-fcgi
PHP max input variables 1000
PHP time limit 30
PHP memory limit 516M
Max input time 60
Upload max filesize 256M
PHP post max size 13M
cURL version 7.68.0 OpenSSL/1.1.1f
Is SUHOSIN installed? No
Is the Imagick library available? No
Are pretty permalinks supported? Yes
Database:
Database size 208,80 MB
Extension mysqli
Server version 8.0.30-0ubuntu0.20.04.2
Client version mysqlnd 7.4.3
Database username wp_user
Database host 127.0.0.1
Database name wp_stage_db
Table prefix wp_
Database charset utf8mb4
Database collation utf8mb4_unicode_520_ci
Max allowed packet size 67108864
Max connections number 151
Wordpress constants:
WP_MEMORY_LIMIT 516M
WP_MAX_MEMORY_LIMIT 256M
WP_DEBUG Disabled
WP_DEBUG_DISPLAY Enabled
WP_DEBUG_LOG Disabled
SCRIPT_DEBUG Disabled
WP_CACHE Disabled
CONCATENATE_SCRIPTS Undefined
COMPRESS_SCRIPTS Undefined
COMPRESS_CSS Undefined
WP_ENVIRONMENT_TYPE Undefined
DB_CHARSET utf8mb4
DB_COLLATE
I have a block that I created and I am looking to update the fields based upon a date range being selected and then having that data update other data that is not touch yed.
<?php
/**
* Composite Reports Block Template.
*
* @param array $block The block settings and attributes.
* @param string $content The block inner HTML (empty).
* @param bool $is_preview True during AJAX preview.
* @param (int|string) $post_id The post ID this block is saved to.
*/
// Global Declarations
global $wpdb;
// Create id attribute allowing for custom "anchor" value.
$id = 'composite_reports-' . $block['id'];
if( !empty($block['anchor']) ) {
$id = $block['anchor'];
}
// Create class attribute allowing for custom "className" and "align" values.
$className = 'composite_reports';
if( !empty($block['className']) ) {
$className .= ' ' . $block['className'];
}
if( !empty($block['align']) ) {
$className .= ' align' . $block['align'];
}
// Load values and assign defaults.
$trainee = get_field('trainee_name') ?: 'Traine Name...';
$date_from = get_field('date_from') ?: date("01/01/2020");
$date_to = get_field('date_to') ?: date("m/d/Y");
$desktop_limit = get_field('desktop_limit') ?: 1000;
$mobile_limit = get_field('mobile_limit') ?: 5;
// echo $trainee . '<br>';
// echo $date_from . '<br>';
// echo $date_to . '<br>';
// echo $desktop_limit . '<br>';
// echo $mobile_limit . '<br>';
$procedureDates = [];
$traineeScores = [];
$attendingScores = [];
echo $trainee;
// Composite Report Data Queries
$results = $wpdb->get_results("SELECT * FROM (SELECT t1.traineeName, t1.procedureDate, t1.surgeryID, t1.traineeRemovesFatAdrenalRating, t1.traineeSkeletonizesRenalVeinRating, t1.traineeSkeletonizesArteryRating, t1.traineeDonorArteriesRating, t1.traineeRenalVeinAugmentationRating, t1.traineeOverallPerformanceRating, t2.doctorRemovesFatAdrenalRating, t2.doctorSkeletonizesRenalVeinRating, t2.doctorSkeletonizesArteryRating, t2.doctorDonorArteriesRating, t2.doctorRenalVeinAugmentationRating, t2.doctorOverallPerformanceRating FROM BackbenchKidneyChartTrainee t1 JOIN BackbenchKidneyChartDoctor t2 ON t1.traineeName = t2.traineeName WHERE t1.surgeryID = t2.surgeryID AND (t1.traineeName = '" . $trainee . "' AND t2.traineeName = '" . $trainee . "') AND " . date(t1.procedureDate) . " BETWEEN '" . $date_from . "' AND '" . $date_to . "' ORDER BY t1.surgeryID DESC LIMIT " . $desktop_limit . ") t3 ORDER BY t3.surgeryID ASC");
//STR_TO_DATE(, '%m/%d/%Y')
$overallResults = $wpdb->get_results("SELECT * FROM (SELECT t1.traineeName, t1.procedureDate, t1.surgeryID, t1.traineeOverallPerformanceRating, t2.doctorOverallPerformanceRating FROM BackbenchKidneyChartTrainee t1 JOIN BackbenchKidneyChartDoctor t2 ON t1.traineeName = t2.traineeName WHERE t1.surgeryID = t2.surgeryID AND (t1.traineeName = '" . $trainee . "' AND t2.traineeName = '" . $trainee . "') AND STR_TO_DATE(t1.procedureDate, '%m/%d/%Y') BETWEEN STR_TO_DATE('" . $date_from . "', '%m/%d/%Y') AND STR_TO_DATE('" . $date_to . "', '%m/%d/%Y') ORDER BY t1.surgeryID DESC LIMIT " . $desktop_limit . ") t3 ORDER BY t3.surgeryID ASC");
$overall = json_encode($overallResults);
if ( ! empty( $overallResults ) ) {
foreach($overallResults as $row) {
array_push($procedureDates, "'" . $row->procedureDate . "'" );
array_push($traineeScores, $row->traineeOverallPerformanceRating);
array_push($attendingScores, $row->doctorOverallPerformanceRating);
}
}
// print_r(array_values($procedureDates)) . '<br>';
// print_r(array_values($traineeScores)) . '<br>';
// print_r(array_values($attendingScroes)) . '<br>';
$procedureDate = implode(', ', $procedureDates);
$traineeScore = implode(', ', $traineeScores);
$attendingScore = implode(', ', $attendingScores);
?>
<script type="text/javascript">
jQuery(function() {
var chart = jQuery('#container').highcharts({
chart: {},
title: {
text: 'Overall Performance'
},
xAxis: {
categories: [<?php echo $procedureDate; ?>]
},
yAxis: {
min: 1,
max: 4,
title: {
text: 'Values'
},
plotLines: [{
}]
},
legend: {
enabled: true,
align: 'center',
verticalAlign: 'bottom',
x: 0,
y: 0
},
credits: {
enabled: false
},
exporting: {
enabled: false
},
series: [
{
name: 'Trainee',
data: [<?php echo $traineeScore; ?>]
},
{
name: 'Attending',
data: [<?php echo $attendingScore; ?>]
}]
}, function(chart) {
});
});
</script>
<div id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr($className); ?>">
<div id="container" style="height: 400px"></div>
</div>
;
Cross post from wordpress support page
In a shop I am working on, I created a few custom fields associated to the product post type. I have a strange issue that cannot debug further. When I publish or update the product, some of the custom fields stay empty (not updating).
What I did for debugging:
– Disabled all the plugins except Woocommerce and ACF
– Changed theme to storefront
– Disable server and website cache
– Check server logs (nothing there)
– Enable wp_debug and also nothing
– Disable every custom code I had in the child theme
What I also found:
– The name doesn’t matter. I created a field called “Box Quantity” and I couldn’t save it. Then I delete all the custom fields and create just this one and it worked. Adding more kept this one working but not the new fields
– Checked the database on the postmeta table and the fields values are not there. So not saved at all.
Those are some of the server settings that might affected it. As you see, values are big enough and I even tried to increase them more with no success.
PHP version 7.2.34
PHP max input variables 6500
PHP time limit 3600
PHP memory limit 3072M
Max input time 1000
PHP post max size 260M
WordPress Version 5.8.2
Advanced Custom Fields Version 5.11.4
WooCommerce Version 6.0.0
Hi everyone here is my situation and question for ACF community,
I am using ACF to make a fairly large web-app, I have 40-50 custom post types and more than 1000 custom fields in total.
Today I am making the heaviest of the post types which has nearly 300 custom fields (those fields include calculated fields, repeater fields, pre-loaded fields if I have to count the repeater fields it’s probably more than 4000 fields in total)
When I get past 100 fields my app started to miss some values on saving, when I save 50-60 custom fields at once, some of them didn’t save. That one time some conditional logics disappeared from my field group all of a sudden.
So my question is, is there a limit what you can do with ACF? Or is it about my hosting plan&provider? What happens when I try to save 1000 fields at once with acf_form from the front-end app?
Is there any other people out there making this kinda heavy projects with ACF PRO?
On my server at Siteground I am using SG optimizer.
I have to do a complete manual flush for every change to a post or a new post. Without this manual flush, changes will never be visible on my site.
The problem is that an item added within ACF Pro (with a registered post-type) in the WP-admin looks like it’s not giving a signal to the object-cache. That way there is never a cache flush like when you save a wp-post or page. Is there a way to achieve the same result as when we’re saving a wp-item?
I already made a support ticket. ACF confirmed the issue, but has no solution at the moment:
Patrick Mwange replied
Hi there,Thanks a bundle for the clarification. I now understand the challenge with SiteGround.
Unfortunately, I’m afraid there is currently no option out of the box from the ACF end to resolve this limitation. I’m going to share the same with the dev team as well for further consideration.
In the meantime, I would recommend that you also open a forum thread on the same. Someone else may have implemented a custom solution that might.
My apologies for the inconvenience.
Maybe someone has a possible solution/workaround already?
Users editing custom post types with ACF WYSIWYG’s on the screen are always defaulting to the “Text” tab. Changing to another tab does not seem to save as the default. This is a recent problem that seems to only be limited to users within a new user role we created that has the following capabilities:
Copy posts, create posts, delete others posts, delete posts, delete private posts, delete published posts, edit others posts, edit posts, edit private posts, edit published posts, manage categories, moderate comments, publish posts, read, read private posts, unfiltered upload, upload files
Admins and editors are not having a problem. Any advice on how to fix or troubleshoot this? Thanks!
Hello,
I am trying out the ACF 5.8.13 (Free) version on WordPress 5.4.2. This is a local machine install on Ubuntu + MySQL 8.0.21.
The problem is that I am unable to add more than 10 (ten) fields to a field group. When I add an 11th field and hit the UPDATE button, the message alert on the top says that the fields have been saved. But, when the field-group refreshes, it only has the first 10 fields.
What I have tried:
1. Create a fresh field group that is not bound to any post type (post type query is blank).
2. Created a field-group, added 10 fields, exported it to JSON (using the Custom Fields > Tools > Export Field Groups), added the 11th field to it using a text editor. Deleted the original field group from WP-ADMIN, cleared it from Trash as well. Imported the modified JSON using the Custom Fields > Tools > Import Field Groups.
I also attempted to trace through the code to figure out what was going on, but with so many filters and nested logic, it was kind of hard to get anywhere. However, I did confirm that both the acf_update_field() and acf_update_field_group() functions were doing their job. In both cases, the fields were reported as committed to the database.
Interestingly, I can see that in the WP_POSTS table in the database, these fields ARE PRESENT. But they do not show up on any UI !
Is this a limitation of the free version?