My code is working, the problem was in wordpress shortcode
Thanks but it seems my code is correct finally.
@jarvis Yes you are right !
Do you know how could i get the taxonomy id ?
thanks
maybe a problem with this ?
https://www.wpallimport.com/documentation/custom-fields/serialized-fields/
I did but the acf images gallery is empty after import.
I i manually add images in the gallery field , this what i get with WP EXPORT
https://mysite.com/wp-content/myimage1.jpg|https://mysite.com/wp-content/myimage2.jpg
So when i put the same url in file to import , the acf gallery is empty after import.
(images files are already in media library, root folder)
Thanks a lot !
actually get_field ( ‘visibilite’, $term->term_id ) is empty and also get_post_meta( $term->term_id , ‘visibilite’)
the value is in databae :
https://snipboard.io/HLsJIG.jpg
i have tried this, but it does no work:
// exclude categories from category dropdown
add_filter('acf/fields/taxonomy/query/name=materiel_client', 'exclude_categories', 10, 2);
function exclude_categories( $args, $field ) {
$terms = get_terms([
'taxonomy' => 'materiel_client',
'hide_empty' => false,
]);
$excluding = array();
foreach ($terms as $term)
{
// $temp.=get_field ( 'visibilite', $term->term_id );
if (get_post_meta( $term->term_id , 'visibilite')=='oui'){
array_push($excluding , get_post_meta( $term->term_id , 'visibilite'));
}
}
$args['exclude'] = $excluding; //the IDs of the excluded terms
return $args;
}
Thanks it is a great news !
If i place acf_form() in a woocommerce checkout hook, do you think it could work ?
https://www.businessbloomer.com/woocommerce-visual-hook-guide-checkout-page/
thanks
Thanks but is it possible to have only one button to save acf field and checkout fields ?
this is what is returned in $field
Array ( [ID] => 0 [key] => field_5a47128676459 [label] => Utilisateur [name] => acf[field_5a47128676459] [prefix] => acf [type] => user [value] => [menu_order] => 0 [instructions] => [required] => 0 [id] => acf-field_5a47128676459 [class] => [conditional_logic] => 0 [parent] => group_5a471067bee5c [wrapper] => Array ( [width] => [class] => [id] => ) [role] => [allow_null] => 0 [multiple] => 0 [return_format] => id [_name] => _user_id [_valid] => 1 [_prepare] => 1 )
I can see yy with this but unfortunately i only see customer role in the list
add_filter(‘acf/prepare_field/key=field_5a47128676459’, ‘my_set_role_filter’);
function my_set_role_filter($field) {
print_r (“yy”);
if (current_user_can(‘shop_manager’)) {
$field[‘role’] = ”;
}
return $field;
}
I can see yy with this but unfortunately i only see customer role in the list
add_filter('acf/prepare_field/key=field_5a47128676459', 'my_set_role_filter');
function my_set_role_filter($field) {
print_r ("yy");
if (current_user_can('shop_manager')) {
$field['role'] = '';
}
return $field;
}
yes i did , strange…
i have tried both…
add_filter('acf/prepare_field/key=field_5a47128676459', 'my_set_role_filter');
function my_set_role_filter($field) {
if (current_user_can('shop_manager')) {
$field['role'] = '';
}
return $field;
}
add_filter('acf/prepare_field/key=acf-field_5a47128676459', 'my_set_role_filter');
function my_set_role_filter($field) {
if (current_user_can('shop_manager')) {
$field['role'] = '';
}
return $field;
}
thanks unfortunately i have tried with name=_user_id and key=select2-acf-field_5a47128676459 but it still display only customers…
oh thanks , and should i complete this ?
$field['role'] = '';
do you mean simply this ? $field[‘role’] = ‘shop_manager’;
my need is that the user shop manager could see all the role in the list (like admnitrator can see). Actually the list is limited to customers.
thanks
i chnage dmy slug values to _0, _1, _2, _3
and i do:
$args = array(
‘post_type’ => ‘maintenance’,
‘posts_per_page’ =>-1,
‘orderby’ => ‘meta_value’,
‘meta_key’ => ‘urgence’,
‘order’ => ‘ASC’,
);
and it seems that it’s ordered by the terms id…and not alphabetically
oh yes this is smart !
may be that also
if ( get_post_status ( $post_id ) ) {
// returns false if post doesnt exist
}
so as i need it for frontend + backend, i must use save_post ?
very strange because same number of items (line items) but white with no text…
what is strange is that when i use the filter as written in demo only to test, my list is empty (there are line items but no text…
function my_post_object_result( $title, $term, $field, $post_id ) {
// add the term's slug to each result
$title .= '(' . $term->slug . ')';
return $title;
}
add_filter('acf/fields/taxonomy/result', 'my_taxonomy_result', 10, 4);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.