Support

Account

Forum Replies Created

  • Ok

    Elliot said :

    I have added compatibility with v4, but I am not adding it to my plugin until Select2 address the issues with sort-ability.

  • I didn’t know about file modal according to user level : it’s perfect as is.

    I already try “attached to the post” but I see no attachment at all. “attached to post” means “attached to CPT” or “attached to post id” ? If it’s post id, it’s normal there is nothing in media library when creating a new post.

    Ok for pre_save and save with wp_set_object_terms, I will look at this.

    Thanks for your help.

  • To make attachment management easier, I put it into categories*.

    I have a ACF form with a file field. When file button is hit, media library modal box appears (I don’t know how to simple have a file uploader in backend like in frontend with ‘uploader’ => ‘basic’). I would like to only display files of this CPT and, obviously, a specific category must be added to this file on upload.

    Is it more understandable ?

    (*) attachment support categories with register_taxonomy_for_object_type( ‘category’, ‘attachment’ ) ; I prefer to use WP Media Category Management for that, because it add select field to filter attachment by category.

  • Hi,

    I currently need to order select/radio by ID (because there’s unfortunately no custom order in WP).

    This :

    
    function my_taxonomy_list( $args, $field ) {
    
        if( $field['name'] == 'acf[field_5478963c3fe12]' )
        {
            $args['orderby'] = 'count';
            $args['order'] = 'DESC';
            return $args;
        }
        else return $args;
    }
    add_filter('acf/fields/taxonomy/wp_list_categories', 'my_taxonomy_list', 10, 2);
    

    used to work but not anymore (I don’t know since when).

    acf/fields/taxonomy/wp_list_categories/name= doesn’t work at all (filter never hits).

  • I agree with you. But example help so much in understanding, whatever the domain. And if people understand ACFPro the will use it, so buy it ๐Ÿ™‚
    Doc is just… doc. When I read about relationship field, I just see doc. When I understand it, I see the power of ACF ๐Ÿ™‚

  • It’s so obvious that I thought he was talking about fronted…

  • Ok, it’s somehow strange for me. I thought it was ACF taxonomy field because it’s a field, in ACF, named Taxonomy. So what’s an ACF taxonomy field if it’s not that ?

    (for the conditional, it can’t be a select2 limitation because it works on backend, using select2)

  • Hi,

    You could do this :

    <?php
    acf_form_head();
    get_header();
    $userID = get_current_user_id();
    if (have_posts()) : while (have_posts()) : the_post(); ?>
    $options = array(
    												'field_groups' => array('your_field_group'),
    												'post_id' => 'user_'.$userID,
    												'updated_message' => __('Profil updated','your_namespace'),								);
    acf_form($options);
    
    get_footer();
    ?>
  • To be clear, I only use ACF taxonomy field, with my own custom taxonomy. I don’t use WP meta box at all. But perhaps I don’t understand something.

    And so, I really have ACF Field Group that only appears if a ACF taxonomy field in another ACF Field Group is a certain value. But only in backend. I simply set Show this field group if [post taxonomy] [is equal to] [my_choice].

    Sincerely, I don’t understand why conditional logic is not possible with ACF taxonomy field. I don’t see why it’s related to WP core. It’s a select or a radio choice : if I select it, display field, if not, hide it. Why it’s so complicated ?

    Anyway, thanks for all your answers.

  • Thanks for this detailed answer !

    Many questions and remarks :

    – First of all, WHY I have to do all this, just because I use taxonomy? Why don’t you better integrate taxonomy in ACF(Pro)?

    – You said

    You also mentioned trying to create a field group that was conditional based on a field in another field group, also not possible, either front or back end

    but it works for me on backend (not in front).

    acf/save_post : it’s ok but as my taxo was not hierarchical, it didn’t really work. So, I don’t think it’s necessary to keep term_id : $term->name in field choices.
    Strangely, you use wp_set_post_terms and it works whereas codex said “For a taxonomy on a custom post type use wp_set_object_terms()”

    acf/pre_save_post : it’s ok. I would like to allow update post but I don’t try to do this for now.

    – …and I still don’t understand why I have to specify ‘field_groups’ for acf_form. What’s the aim of location rules if it doesn’t work ?

    Thanks.

  • On my example, I specify field_groups because I have to in order to display it. If I don’t, I only have the submit button.

    The reason why the field groups will not appear without specifying them is that your field groups location rule is to display on the โ€œPostโ€ post type and you are displaying the form on a โ€œPageโ€

    No ! My location rule is :
    Post type is equal to “document” —> OR <—
    Page is equal to “add document”

    And, of course, “Add document” is a page.

    Yes, you could have optional fields based on the taxonomy field

    What ?! Since when ? It doesn’t work for me !

    First field :
    “Type of document”,
    taxonomy,
    required,
    taxonomy : my own,
    appearance : radio buttons.

    Second field (only displayed if a specific taxo term is choosen) :
    “Keywords”,
    taxonomy,
    required : no,
    taxonomy : my own 2,
    conditional logic : yes -> Show this field if [No toggle fields available].

  • Of course I have acf_form() !

    Here is the full code of this page :

    <?php acf_form_head(); ?>
    <?php get_header(); ?>
    
    </script>
    
    <div id="content">
    
    <div id="inner-content" class="wrap cf">
    
    <main id="main" class="m-all t-2of3 d-5of7 cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf' ); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
    
    		<header class="article-header">
    
    			<h1 class="page-title" itemprop="headline"><?php the_title(); ?></h1>
    
    		</header> <?php // end article header ?>
    
    		<section class="entry-content cf" itemprop="articleBody">
    
    				<?php
    
    					$options = array(
    						'field_groups' => array('group_54dcecbb2f254','group_54ddd77bb7f6b'),
    						'post_id' => 'new_post',
    						'new_post'		=> array(
    							'post_type'		=> 'post',
    							'post_status'	=> 'pending',
    						),
    						'submit_value' => __('Add this document', 'xxx'),
    						'updated_message' => __('Document added.','xxx'),
    						'uploader' => 'basic',
    					);
    					acf_form($options);
    
    				?>
    
    		</section>
    
    	</article>
    
    <?php endwhile; endif; ?>
    
    </main>
    
    </div>
    
    </div>
    
    <?php get_footer(); ?>

    This code works because I specify field_groups ; without this value, nothing appears but the submit button.

    So, it’s totally impossible to display a group field (or, better, some fields into a group field) depending on a taxonomy field ? It’s very very awkward !

  • Ok. For this, I do as follow (excerpt from my code, so probably not perfect at all) :

    foreach( $args as $key => $value ) {
    
            $meta_query = array ( // logical operator between search field
                              'relation'  => 'AND',
                          );
    
            $meta_query[] = array(
                    'key'       => $key,
                    'value'     => $value,
                    'compare'   => 'IN',    // 'IN' if $value is an array, '=' for string
    
                );
    
    }
    $wp_query = new WP_User_Query( array( 'meta_query' => $meta_query ) );
    $resultats = $wp_query->get_results();
  • “If you assigned the field groups to the โ€œpageโ€ post type they would automatically be added”

    I have a CPT named “Document”. I have a ACF field group.
    On this group, I said :

    Show this field group if
    [Post type] [is equal to] [document]   -> it works
    or
    [Page] [is equal to] [my_page]         -> it doesn't work

    “You have a field group that appears based on a selection in another field group?”

    Yes. As conditional logic doesn’t work with taxonomy (very unfortunately despite many requests), I created another field group and I said :

    Show this field group if
    [Post taxonomy] [is equal to] [specific_choice_I_want]

    “specific_choice_I_want” is a value of a taxonomy field in my first field group.
    It works in backend (creating a new post in my CPT). It doesn’t work in frontend, even if I add field_group id to options.

  • Hi,

    What do you want to do ? Search users with specific values on ACF fields ?

    Because otherwise, WP_User_Query is a WordPress class, not ACF.

  • I agree with you, but forum is made to be sort of a knowledge base. If you don’t give your solution, you’ll not help anyone.

  • You can’t include ACF field in csv import, you have to add this functionality in plugin.

    You don’t need field id generated by ACF to use meta values. Just call WP_User_Query with a meta_query.

  • Yes, it’s normal. I’ve the same problem with users import in csv. There is no native possibility with ACF (even pro). If you want that, you have to include it in csv plugin.

    PS : That said, you don’t necessarily need field id. I work without it and all functionality I want works fine. Try not to be too ACF dependant.

  • Now simply use ‘uploader’ => ‘basic’ in wp_form() options.

  • Easily search posts with same fields I have when I create my post.

    For example, each member of my site can modify their profile (made with custom fields) in frontend. I would like to create a similar form to search members (by name, profession, skills, etc.)

    Thanks.

  • It seems the problem remains. I have to massively import users but wp_update_user() or update_user_meta() don’t create field_id.
    And, apparently, there’s no ACF alternative (if you want to update a field’s value, you must have the field_id).
    How can we do ?
    Thanks.

  • Ok, thank you. It’s not very optimized for DB speed to store list of values serialized, it’s strange…

  • Thank you for your job @elliot : it’s now ok with acf_form() option ‘uploader’ set to ‘basic’.
    See here acf_form() options

  • Exactly what I’m searching to do. Do you find a solution ?

Viewing 25 posts - 1 through 25 (of 28 total)