Support

Account

Forum Replies Created

  • Something like this will work for you. You will want to expand on this function to make sure the $imagearray and several other security checks.

    function my_acf_save_post( $post_id ) {
        $user_id = get_current_user_id();
        $imagearray = get_field('user_image','user_' . $user_id);
        $imagepath = $imagearray['url'];
        update_field('image_url', $imagepath);
    }
    add_action('acf/save_post', 'my_acf_save_post', 20);
  • Whats on the page are you trying to update. Are you able to do a simple window.location.reload(); ajax return? This makes me cringe knowing what is coming with Gutenberg.

  • The following page goes over the details of what you have to do to include it into your theme. You do not have to use the licensing system as it will not be installed through the plugins system but rather hard coded into your theme.

    The page also includes sample code to show you how to install it.

    I also have some sample code if you need it that will disable any existing copies of pro and make yours the highest priority preventing theirs from loading.

    https://www.advancedcustomfields.com/resources/including-acf-in-a-plugin-theme/

  • The best option without knowing your programming skills is to add the following plugin.

    https://wordpress.org/plugins/acf-gravityforms-add-on/

    It adds a gravity forms input type were you can select the form from a select box similar to the post object.

  • I am dealing with this glitch as well. It does not work when setting icon or declaring the array with src

  • This code fixes the WordPress save function. I have also submitted this as a bug so hopefully they fix it.

    add_action( 'admin_print_footer_scripts', 'mediaArrayFix', 11 );
    	function mediaArrayFix() {
    		// Make sure the media-views script has been enqueued.
    		if(!did_action( 'wp_enqueue_media' ) ){ return; }
    		?>
    		<script>
    		wp.media.view.AttachmentCompat.prototype.save = function( event ) {
    			var data = {};
    			if ( event ) { event.preventDefault(); }
    			_.each( this.$el.serializeArray(), function( pair ) {
    				if ( /\[\]$/.test( pair.name ) ) {
    					if ( undefined === data[ pair.name ] ) { data[ pair.name ] = []; }
    					data[ pair.name ].push( pair.value );
    				}else{ data[ pair.name ] = pair.value; }
    			});
    			this.controller.trigger( 'attachment:compat:waiting', ['waiting'] );
    			this.model.saveCompat( data ).always( _.bind( this.postSave, this ) );
    		};
    		</script>
    		<?php
    	}
  • I found the issue and now it is about trying to find the solution.

    Open wp-includes/js/media-views.js
    Line: 8353

    _.each( this.$el.serializeArray(), function( pair ) {
        data[ pair.name ] = pair.value;
    });

    This is the js code wordpress is using to collect the form data for submission. It effectively removes the array submitted. I submitted this as a bug on their forums but we will see how they reply.

  • When you add the field there is a select box for you to choose Term Object or Term ID

  • This is because it is returning an array. You may want to read up on the documentation for each field to see how the arrays are formed

    https://www.advancedcustomfields.com/resources

  • I have not tested this but it should be what you are looking for. You can simply use the user field type which returns the user id. This will override the default user id system with your custom one as it makes this change after the post was saved.

    function my_acf_save_post( $post_id ) {
        // get new value
        $user_id = get_field('CUSTOM_AUTHOR');
    	if($user_id){
    		wp_update_post( array( 'ID'=>$post_id, 'post_author'=>$user_id) ); 
    	}
    }
    add_action('acf/save_post', 'my_acf_save_post', 20);
  • OK… After a day of messing around and testing everything I found the fix. I dont quite understand why it works in this way but it does. With ID it would display the field with no entries but with key it displays both.

    I had to change
    $fields['images']['ID']
    to
    $fields['images']['key']

  • The point I was trying to make is that you cant do what you are looking to do. The type=”number” field does not allow the use of anything other than numbers. If you want to use commas, periods or any other symbol you have to use a text field and prevent the use of letters. ACF is not going to add documentation for something that is not possible.

  • 1. My bad I pulled the function from one of my class files.
    2. I was thinking it was returning a comma seperated list.

    change the following
    return str_replace(',','<br>',$content);
    to
    return implode('<br>',$content);

  • Speed depends completely on the number of posts and speed of your server. As for scheduling you can look at the following link for a WordPress Scheduled Event. You can set this so it runs the first time someone visits the site each day. The other option would be to create a cron job but I will let you look that up if you need it.

    https://codex.wordpress.org/Function_Reference/wp_schedule_event

  • Yes I have created testimonial systems using ACF. I am board this morning so I will help you along.

    Create Testimonial Post Type in your functions.php

    
    $labels = array( 
    	"name" => __( 'Testimonials', 'themeSlug' ),
    	"singular_name" => __( 'Testimonial', 'themeSlug' ),
    	"menu_name" => __( 'Testimonials', 'themeSlug' ),
    	"all_items" => __( 'All Testimonials', 'themeSlug' ),
    	"add_new" => __( 'Add New', 'themeSlug' ),
    	"add_new_item" => __( 'Add New Testimonial', 'themeSlug' ),
    	"edit_item" => __( 'Edit Testimonial', 'themeSlug' ),
    	"new_item" => __( 'New Item', 'themeSlug' ),
    	"view_item" => __( 'View Testimonial', 'themeSlug' ),
    	"search_items" => __( 'Search Testimonials', 'themeSlug' ),
    	"not_found" => __( 'No Testimonials Found', 'themeSlug' ),
    	"not_found_in_trash" => __( 'No Testimonials in trash', 'themeSlug' ),
    	"parent_item_colon" => __( 'Parent Testimonial', 'themeSlug' ),
    	"archives" => __( 'Testimonial Archives', 'themeSlug' ),
    	"insert_into_item" => __( 'Insert into Testimonial', 'themeSlug' ),
    	"uploaded_to_this_item" => __( 'Uploaded to this Testimonial', 'themeSlug' ),
    	"filter_items_list" => __( 'Filter Testimonial List', 'themeSlug' ),
    	"items_list_navigation" => __( 'Testimonial list navigation', 'themeSlug' ),
    	"items_list" => __( 'Testimonials List', 'themeSlug' ),
    	"parent_item_colon" => __( 'Parent Testimonial', 'themeSlug' )
    );
    $args = array(
    	"label" =>'Testimonials', 
    	"labels" => $labels,
    	"description" => "",
    	"public" => true,
    	"publicly_queryable" => true,
    	"show_ui" => true,
    	"show_in_rest" => false,
    	"rest_base" => "",
    	"has_archive" => true,
    	"show_in_menu" => true,
    	"exclude_from_search" => false,
    	"capability_type" => "post",
    	"map_meta_cap" => true,
    	"hierarchical" => false,
    	"rewrite" => array( "slug" => "testimonials", "with_front" => true ),
    	"query_var" => true,
    	"supports" => array( "title","editor" ),
    	"menu_icon" => "dashicons-format-status",
    );
    register_post_type( "testimonials", $args );

    Create Front End Form in a page template file. This one will save the post as pending so you can login and approve.

    See https://www.advancedcustomfields.com/resources/acf_form/ for more form settings

    
    acf_form(array(
             'post_id' => 'new_post',
             'field_groups' => array(6), // Used ID of the field groups here.
             'form' => true,
             'new_post' => array(
                 'post_type' => 'testimonials',
                 'post_status' => 'pending'
             ),
             'submit_value' => 'Submit Book',
         ));
  • I thought you were including it in a template not looking for a filter.

    If you are using an ACF image field on your page to include the image or including the image in your content you will have to build it into your template or create a short code.

    If you are using WordPress’ Featured Image system you can include the following and changing your custom field accordingly.

    
    add_filter('post_thumbnail_html', 'my_thumbnail_filter_method', 10, 5 );
    function my_thumbnail_filter_method($html, $post->ID, $post_thumbnail_id, $size, $attr) {
        $id = get_post_thumbnail_id();
        $src = wp_get_attachment_image_src($id, $size); 
        $alt = get_the_title($id);
        $class = $attr['class'];
    	$attr = get_field('CUSTOM FIELD NAME',$post->ID);
        $html = '<img src="' . $src[0] . '" alt="' . $alt . '" class="' . $class . '" data-attr="" />';
        return $html;
    }
  • I use this in one of my in house themes. It simply checks if the current page has a locations field which would require a google map. We then check if google_maps_api function exists in case we forgot to include it. then we enqueue the script to be added in the footer. You can change true to false if you want it in the header.

    add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' );  
    function wpb_adding_scripts() {
        global $post;
        if(!empty(get_field('locations',$post->ID)){
    		if(function_exists('google_maps_api')){
    			$apiKey=google_maps_api();
    			if($apiKey){
    				wp_register_script('googleMapsAPI', 
    					'https://maps.googleapis.com/maps/api/js?key='.$apiKey,
    					'',
    					true
    				);
    				wp_enqueue_script('googleMapsAPI');			
    			}
    		}
        }
    }
  • It is my understanding that the entire reason for using acf is to avoid having to use customizer. With ACF you can create much nicer options pages with better permissions and usability that customizer has ever had.

  • Everything should work correctly even without the plugin. The only issue I have seen so far is that ACF does not remove the gutenberg editor if the hide checkbox is clicked when creating the field group.

    I would suggest installing the gutenberg plugin to try it out and see what changes actually effect you. Since we all have our own coding structures things can change from one site to the other.

  • You can disable this popup by including the following. I have not tested it on the newest version but we had it working about a year ago.

    
    jQuery( document ).ready( function() {
        // disable the ACF js navigate away pop up
        acf.unload.active = false;
    } );
  • I am on a roll answering everyone’s questions today so here we go with another…

    This function will run every time a field is updated to check if your field needs to be checked. If your field is found it checks the value to see if it has changed since last update. If it has it will run your api call and update the other fields necessary as declared by you.

    
    function my_acf_update_value( $value, $post_id, $field  ) {
        // only do it to certain custom field
        if( $field['name'] == 'custom_field_name' ) {
    		
            // get the old (saved) value
            $old_value = get_field('custom_field_name', $post_id);
            
            // get the new (posted) value
            $new_value = $_POST['acf']['field_1234567890abc'];
            
            // check if the old value is the same as the new value
            if( $old_value != $new_value ) {
                
    			// do your api call functions and return you size and what not
    			
    			update_field('sizeField',$sizeValue, $post_id);
    
            }
        }
    	// don't forget to return to be saved in the database
        return $value;
        
    }
    
    // acf/update_value - filter for every field
    add_filter('acf/update_value', 'my_acf_update_value', 10, 3);
    
    
  • I am guessing you are having some sort of plugin conflict or missing file during installation. I have this running on several multi sites without any glitches or errors.

  • https://www.advancedcustomfields.com/resources/options-page/

    I use thees daily. The options page gives you the ability to add all your fields on a special page added to the left admin bar. From their you can call all your options with get_field('FieldName','option');

  • There is no need for documentation. They just give you an HTML5 input type=”number” which as a step, min, and max attributes with they provide access to. This is not something custom that ACF has added to their system. You can read more about it below.

    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number

    If you are looking to create custom filtration you will have to look at some type of validation script whether it be html5 validation or a jQuery library.

  • I created the following shortcode for you [acfBr field="FIELD_NAME"]. This will get the field and replace all the commas with <br> tags before it returns the result.

    Paste the following code at the bottom of your functions.php document in your theme folder.

    add_shortcode('acfBr', 'brListFunction');
    public function brListFunction($atts, $content) {
    	extract(shortcode_atts(array("id"=>'','field'=>''),$atts));
    	if($field){
    		if($id=''){
    			global $post;
    			$id=$post->ID;
    		}
    		$content=get_field($field,$id);
    		return str_replace(',','<br>',$content);
    	}
        return '';
    }

    This shortcode was created just for your lists and may not work correctly for all your other fields. If you have any issues please let me know.

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