Support

Account

Forum Replies Created

  • Hello:

    Once the post has been created, to allow the user to edit the data instead of passing “new_post” as the value for post_id you need to pass the id of the post. When the post id is passed, the form will load the existing data for editing.

    Hope this is helpful!

  • I think it may have been the space in the image size name.

    `add_image_size( ‘home-page-portrait size’, 750, 1000, false );’

    I don’t think image size names can have spaces as they are slugs. This would work:

    ‘add_image_size( ‘home-page-portrait’, 750, 1000, false );’

  • In your first example you are using the category__in argument which can only be used with the category taxonomy.

    In WooCommerce the product category taxonomy is a custom taxonomy. Since it is a custom taxonomy instead of using category__in in your second example you should use a tax_query. Take a look at the tax_query documentation for wp_query, it is pretty intuitive to set up if you are not familiar with it.

    Hope this is helpful!

  • Since you are using global $post one thing that occurred to me is if there are any custom queries on the page make sure that wp_reset_postdata() is called. It could be that somewhere in your template the global $post variable is being reassigned without being reset.

    Not sure if this is relevant but hope this is helpful!

  • Here is a tutorial for adding custom fields to a WooCommerce product and displaying them on the products template:

    https://themeisle.com/blog/custom-fields-woocommerce/

    Another option for displaying the values from your ACF fields on the products template outside of using the short codes which the above tutorial does not get into is WooCommerce provides a number of hooks/filters that can be used with the single products template to add information/customize the output. These hooks/filters can be placed in the functions file of your theme to output the additional ACF fields you want to include on the products template.

    Hope this is helpful!

  • I was able to figure out answers for all of my questions from my previous post above by looking at the array structure for the toolbars provided in the documentation for the toolbars filter. Thanks again for providing the detailed information in this documentation which allowed me to answer my questions about modifying the toolbars.

    For those who might need a similar solution, here are the answers to my questions:

    1. The special character button can be added in the same manner as the bold, italic, underline buttons as outlined in the documentation. Just add “charmap” to the array.

    2. Similarly the paste as text button can be added in the same manner as outlined in the documentation. Just add “pasteastext” to the array.

    3. Additional buttons can be added to the Basic toolbar simply by adding the code for the button to the end of the array for the row in the toolbar you want to add the button to. For example to add the special character button to the first row of buttons for the Basic toolbar:

    
    $toolbars['Basic' ][1][] = 'charmap';
    

    4. Data is not lost when editing the toolbar options, whether adding a new toolbar or modifying an existing toolbar.

    Thanks again for the excellent documentation provided here on the ACF site!

  • Hi Rawland:

    I submitted a response this morning, I think my comment was held for moderation. I kept accidentally submitting my response before I was finished typing, I think I submitted too many edits in a short time period. Here is my response again:

    The second is the correct format for your field key (field_5cdde36032dd0). All ACF field keys begin with “field_” followed by the unique identifier string.

    I checked the Mail Chimp documentation (https://www.mc4wp.com/kb/syncing-custom-user-fields-mailchimp/) and it looks like theoretically ACF fields should be able to be synced using the Send Additional Fields feature of the Mail Chimp plugin (shown in your screenshot), as ACF stores fields attached to users as user meta. Try using both the field key and the field name in the form and see if that works.

    If not you could try the filter solution outlined at the bottom of the Mail Chimp documentation under the heading Advanced Fields. Here is an example of how this filter might be used:

    
    add_filter( 'mc4wp_user_sync_subscriber_data', function( $subscriber, $user ) {
        //Get the user id
        $user_id = $user->ID;
        //Format the user id for ACF
        $acf_user_id = 'user_' . $user_id;
        //Get the value for your custom field using the field name
        $my_custom_field_value = get_field('my_custom_field_name', $acf_user_id);
        //Sync the custom field value with the Mail Chimp field you want to store it in
        $subscriber->merge_fields['MY_FIELD'] = $my_custom_field_value;
        return $subscriber;
    }, 10, 2 );
    

    Hope that information is helpful! I am just a community member and am not part of ACF staff (I am just pawn in game of ACF). Someone from the staff may be able to better advise you if this info doesn’t work.

  • The second value you listed above (field_5cdde36032dd0) is the correct format for the key for an ACF field. ACF field keys always start with field_ followed by the string that is the unique identifier.

    I took a look at the Mail Chimp documentation (https://www.mc4wp.com/kb/syncing-custom-user-fields-mailchimp/) and I am not sure if the send additional fields feature (shown in your screenshot above) can be used with ACF fields. Theoretically this should work as ACF stores the custom field as part of the user meta. Try using both the field key and the field name in the send additional fields form and see if that works.

    If not you could also try the filter outlined at the bottom of the Mail Chimp documentation (under the heading Advanced Fields). I haven’t tested this but here is an example of how this filter might be used:

    
    add_filter( 'mc4wp_user_sync_subscriber_data', function( $subscriber, $user ) {
        //Get the user id
        $user_id = $user->ID;
        //Format the user id for ACF
        $acf_user_id = 'user_' . $user_id;
        //Get the value for your custom field using the field name
        $my_custom_field_value = get_field('my_custom_field_name', $acf_user_id);
        //Sync the custom field value with the Mail Chimp field you want to store it in
        $subscriber->merge_fields['MY_FIELD'] = $my_custom_field_value;
        return $subscriber;
    }, 10, 2 );
    
    

    Hope this info is helpful! Note I am not on ACF support staff, someone from ACF may be able to provide you with a better answer.

  • Hi John:

    Thanks for getting back to me. The solution you provided above is exactly what I was looking for. I went through the filters documentation before posting here, sorry I missed this!

    Thanks again for your help, I really appreciate the excellent support you provide here.

  • I was able to figure this out, turned out to be a simple answer of course! The taxonomy field returns value in an array (for example $_POST[‘acf’][‘field_5b7cf5019f615’]), I was able to use this to retrieve the ID of the term selected.

    The search form I outlined above worked out well. I was able to use the pre_save_posts field to store fields values from the form in the session and use them to search my publications archive. I was also able to use the load value filter on the taxonomy field to keep the last term searched selected.

    I continue to be impressed with how thorough this plugin is, lots of tools available when you need something somewhat custom like this.

  • Hi Hidieh:

    You can use the id parameter (one of the arguments passed to acf_form) to create a unique id for each of your forms. In your function triggered by the submit form action then use the global for acf_form to retrieve the ID value ($GLOBALS[‘acf_form’]).

    See Elliot’s responses in this thread (though the original question is different from what you are asking) for more detail:

    https://support.advancedcustomfields.com/forums/topic/acf_form-id-not-being-set-from-args/

    Hope this is helpful!

  • Hi John:

    Thanks for getting back to me an sorry I didn’t have a chance to get back to you earlier. I was already using the code you linked to generate the excerpt at a custom word length, found this solution when researching this for another project a couple years ago (thanks for linking to this again, excellent solution).

    What I am still confused about is even when I set a more tag at a specific spot in the text (through the toolbar for the WYSIWYG field), the more tag doesn’t appear to be returned when getting the field contents in with get_field. I thought I might have made a template error in not checking for the more tag, however it doesn’t appear to be there at all. Is there something in the get_field function which is stripping out the more tag?

    No rush on this, please get back to me when you have a chance. Thanks again for your help!

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