Support

Account

Home Forums Search Search Results for '%s'

Search Results for '%s'

reply

  • @bulldogsnare As I can understand, you have created a date field for the product category taxonomy and you want to display it in your product category archives. Here is one approach to do that –

    function tax_date_field(){
    
    	// get the current taxonomy term
    	$term = get_queried_object();
    
    	//ACF field
    	$date = get_field('class_dates', $term);
    	$class_date = '';
    
    	if( is_tax('product_cat') && $date ) {
    		$class_date = sprintf(
    			'<div class="class-date"><label>%s</label>%s</div>',
    			esc_html__('Post Dates:', 'your-themes-text-domain'),
    			esc_html( $date )
    		);
    	}
    
    	return $class_date;
    
    }

    Now you can echo the function to your product category archives. To do that, WooCommerce have some hooks for the taxonomy archive page which you can find inside archive-product.php template file inside WooCommerce plugin folder.

    Here I am hooking it to woocommerce_before_shop_loop. In your functions.php –

    add_action('woocommerce_before_shop_loop', 'show_post_dates', 11);
    function show_post_dates(){
    	echo tax_date_field();
    }

    Now the field will be shown at product taxonomy archives. Let me know if you have any questions.

  • Nope – its not.

    And no other code targeted at this particular field other than registering the form itself and setting candidate email as an admin column on my post type in Wp-Admin.

    Here the form code for reference:

    // 1. Candidate Application Form
    
        //Defines the fields to display
        $fields = array(
            'field_5db9db36a28bf',	    // candidate first name
            'field_5e06338abb373',      // candidate last name
            'field_5db9db5da28c0',	    // candidate email
            'field_5db9dc8ca28c1',	    // candidate contact number
            'field_5dcc08f0a11b5',      // candidate gender
            'field_5dcc092ba11b6',      // candidate race
            'field_5dcc09e2a11b7',      // candidate nationality check
            'field_5dcc0a32a11b8',      // candidate nationality
            'field_5e42e3cf90206',      // candidate work permit check
            'field_5e42e43490207',      // candidate work permit doc
            'field_5e42e30990204',      // candidate notice period
            'field_5e42e35190205',      // candidate disability check
            'field_5e42e47390208',      // candidate criminal record check
            'field_5e5bf8b8e879b',      // candidate language proficiency
            'field_5db9dd10a28c2',	    // candidate cv
            'field_5db9ddf5a28c4',      // candidate supporting docs
            'field_5dba152669aaf',      // candidate vacancy applied for
            'field_5dcc0f15030b6',       // candidate disclaimer
            'field_5ec4e941df19d'       // duplicate check
    
        );
    
        // Sets the ACF Form
        acf_register_form(
    
        // Defines all the settings associated with the ACF Form 
        array(
    
            /* (string) Unique identifier for the form. Defaults to 'acf-form' */
            'id' => 'acf-candidate-application-form',
    
            /* (int|string) The post ID to load data from and save data to. Defaults to the current post ID. 
            Can also be set to 'new_post' to create a new post on submit */
            'post_id' => 'new_post',
    
            /* (array) An array of post data used to create a post. See wp_insert_post for available parameters.
            The above 'post_id' setting must contain a value of 'new_post' */
            'new_post' => array(
                'post_type'		=> 'candidates',
                'post_status'	=> 'publish',
            ),
    
            /* (array) An array of field group IDs/keys to override the fields displayed in this form */
            'field_groups' => false,
    
            /* (array) An array of field IDs/keys to override the fields displayed in this form */
            'fields' => $fields,
    
            /* (boolean) Whether or not to show the post title text field. Defaults to false */
            'post_title' => false,
    
            /* (boolean) Whether or not to show the post content editor field. Defaults to false */
            'post_content' => false,
    
            /* (boolean) Whether or not to create a form element. Useful when a adding to an existing form. Defaults to true */
            'form' => true,
    
            /* (array) An array or HTML attributes for the form element */
            'form_attributes' => array(),
    
            /* (string) The URL to be redirected to after the form is submit. Defaults to the current URL with a GET parameter '?updated=true'.
            A special placeholder '%post_url%' will be converted to post's permalink (handy if creating a new post)
            A special placeholder '%post_id%' will be converted to post's ID (handy if creating a new post) */
            //'return' => home_url('candidate-application-success'),
    
            /* (string) Extra HTML to add before the fields */
            'html_before_fields' => '',
    
            /* (string) Extra HTML to add after the fields */
            'html_after_fields' => '',
    
            /* (string) The text displayed on the submit button */
            'submit_value' => __("Submit Application", 'acf'),
    
            /* (string) A message displayed above the form after being redirected. Can also be set to false for no message */
            'updated_message' => __("Application successfully submitted", 'acf'),
    
            /* (string) Determines where field labels are places in relation to fields. Defaults to 'top'. 
            Choices of 'top' (Above fields) or 'left' (Beside fields) */
            'label_placement' => 'left',
    
            /* (string) Determines where field instructions are places in relation to fields. Defaults to 'label'. 
            Choices of 'label' (Below labels) or 'field' (Below fields) */
            'instruction_placement' => 'field',
    
            /* (string) Determines element used to wrap a field. Defaults to 'div' 
            Choices of 'div', 'tr', 'td', 'ul', 'ol', 'dl' */
            'field_el' => 'div',
    
            /* (string) Whether to use the WP uploader or a basic input for image and file fields. Defaults to 'wp' 
            Choices of 'wp' or 'basic'. Added in v5.2.4 */
            'uploader' => 'basic',
    
            /* (boolean) Whether to include a hidden input field to capture non human form submission. Defaults to true. Added in v5.3.4 */
            'honeypot' => true,
    
            /* (string) HTML used to render the updated message. Added in v5.5.10 */
            'html_updated_message'	=> '<div id="message" class="updated"><p>%s</p></div>',
    
            /* (string) HTML used to render the submit button. Added in v5.5.10 */
            'html_submit_button'	=> '<input type="submit" class="acf-button button button-primary button-large" value="%s" />',
    
            /* (string) HTML used to render the submit button loading spinner. Added in v5.5.10 */
            'html_submit_spinner'	=> '<span class="acf-spinner"></span>',
    
            /* (boolean) Whether or not to sanitize all $_POST data with the wp_kses_post() function. Defaults to true. Added in v5.6.5 */
            'kses'	=> true
    
        )
    );

    Running ACF Pro v 5.8.6

  • ACF uses the built in wp_list_categories() function to show terms as checkboxes. I don’t know if you can alter the arguments for this function to do what you want. Here is the code from ACF

    
    		
    		// vars
    		$args = array(
    			'taxonomy'     		=> $field['taxonomy'],
    			'show_option_none'	=> sprintf( _x('No %s', 'No terms', 'acf'), strtolower($taxonomy_obj->labels->name) ),
    			'hide_empty'   		=> false,
    			'style'        		=> 'none',
    			'walker'       		=> new ACF_Taxonomy_Field_Walker( $field ),
    		);
    		
    		
    		// filter for 3rd party customization
    		$args = apply_filters('acf/fields/taxonomy/wp_list_categories', $args, $field);
    		$args = apply_filters('acf/fields/taxonomy/wp_list_categories/name=' . $field['_name'], $args, $field);
    		$args = apply_filters('acf/fields/taxonomy/wp_list_categories/key=' . $field['key'], $args, $field);
    		
    		?>
    <div class="categorychecklist-holder">
    	<ul class="acf-checkbox-list acf-bl">
    		<?php wp_list_categories( $args ); ?>
    	</ul>
    </div>
    
  • Oke, I am little bit further. I managed to create a post and a user but I am not yet there.

    This is what I use in my template:

    while (have_posts()) {
        the_post();
        
        acf_form(array(
            'post_id'       => 'new_post',
            'submit_value'  => 'Register user',
            'uploader' => 'basic',
            'updated_message' => 'Well done! You made an account and a post.',
            'html_updated_message'  => '<div style="background: rgba(31,205,80,.2); padding: 10px 20px; border-radius: 4px;" class="updated"><p>%s</p></div>',
            'new_post' => array(
                'post_type'     => 'my-cpt',
                'post_status'   => 'publish'
            ),
        ));
    }

    This is what I have now in my functions.php:

    function create_user_via_acf($post_id) {
    	
    	$username = get_field('username',$post_id);
    	$password = get_field('password',$post_id);
    	$email = get_field('email',$post_id);
    	$categories = get_field('categories',$post_id);
    
    	// creating the user
    	$userdata = array (
    		'user_login'    => $username .'-'. generate_random_user_number(),
    		'user_email'    => $email,
    		'user_pass'     => $password,
    		'post_category' => $categories
    	);
    	$user_id = wp_insert_user($userdata);
    	
    	// overwriting the post I created with acf_form()
    	$arg = array(
    		'ID' => $post_id,
    		'post_author' => $user_id,
    		'post_title' => $username .'-'. generate_random_user_number(),
    		'post_content'  => 'content overwritten',
    	);
    	wp_update_post($arg);
    	
    	return $post_id;
    	
    	//wp_delete_post($post_id); //this does not delete the second post
    	
    }
    add_action('acf/save_post', 'create_user_via_acf', 20);

    In the function above, I try to delete the extra post, wich does not work. I do not know why. Further more, I also see there are 2 posts being created, this should be one. Also the title of the post should be the same as the user I am trying to create.

    I created a function wich returns a random integer of 3 numers (generate_random_user_number()) wich I append to the username and post. But it creates one user with e.g. username-123 and 2 posts with post-456 and post-789. Just an example to point out the digits aren’t the same. For different reasons I use the a number wich is called upon 3 times since it generates 3 different numbers.

    It should be post-123 and username-123. Username-123 should automaticly the post_author of post-123. But I just can’t get my head around this.

    I also used add_filter(‘acf/pre_save_post’) but that did not work either.

    Does anybody have any thoughts on this? A lot of thanks in advance.

  • SOLVED
    my link is like https://domain/?user=1&parent=165
    i place this code into my page template

     <?php
    if (isset($_GET['user']))
    {
        $user = $_GET['user'];
    } else {
    	$user = '1';
    }
    	acf_form(array(
    	 'id' => 'form',
             'post_id' => 'new_post',
             'field_groups' => array(ID), // Used ID of the field groups here.
             'post_title' => true, // This will show the title filed
             'post_content' => false, // This will show the content field
             'form' => true,
             'new_post' => array(
                 'post_type' => 'customer_data',
    			 'post_author' => $user,  // Where $user_id is a number
                 'post_status' => 'publish' // You may use other post statuses like draft, private etc.
             ),
    		 // 'return' => '/?user=' . $user . '&parent=%post_id%',
             'submit_value' =>__("Submit Addons", 'acf'),
    		 'html_submit_button'  => '<input type="submit" id="next" class="acf-button button button-primary button-large" name="addons_btn" value="%s" />
    		 <input type="submit" id="done" class="acf-button button button-primary button-large" value="Submit Details" style="position: relative; float:right;" />',
         ));
    ?>

    add some JS

    <script type="text/javascript"> 	
    $(document).ready(function(){
    	$("#next, #done").click(function(e) {
    		$("<input />").attr("type", "hidden")
    			.attr("name", "acf[submittype]")
    			.attr("value", e.target.id)
    			.appendTo("#form");
    	});
    });
    </script>

    I also add some code on functions.php

    add_action('acf/submit_form', 'my_acf_submit_form', 10, 2);
    function my_acf_submit_form( $form, $post_id ) {
    	if ($_POST['acf']['submittype'] == 'next') {
    		wp_redirect( 'first_link');
    	} else {
    		wp_redirect('another_link');
    	}
        exit;
    }
  • Hello,

    i try to add values to woocommerce product permalink.

    my code :

    //add rewrite rules 
    function product_add_rewrite_rules() {
    	global $wp_rewrite;
        
    	$wp_rewrite->add_rewrite_tag('%product%', '([^/]+)', 'product=');
    	$wp_rewrite->add_rewrite_tag('%subtitle%', '([^/]+)', 'subtitle=');
    	$wp_rewrite->add_rewrite_tag('%artiste%', '([^/]+)', 'artiste=');
    	$wp_rewrite->add_rewrite_tag('%numero_de_page%', '([^/]+)', 'numero_de_page=');
    	$wp_rewrite->add_permastruct('product', '/catalogue/%artiste%-%product%-%subtitle%-page-%numero_de_page%/', false);
        
        $wp_rewrite->flush_rules();
    }
    add_action('init', 'product_add_rewrite_rules', 10, 0);
    
    // replace the rwrite tag by the content
    function product_permalinks($permalink, $post, $leavename) {
    	$post_id = $post->ID;
    
    	if ($post->post_type == 'product') {
    		$subtitle = sanitize_title(get_field('subtitle', $post_id));
    		$artiste = get_field('artiste', $post_id);
            $artistesurname = sanitize_title($artiste->name);
    		$pagenumber = sanitize_title(get_field('numero_de_page', $post_id));
    		if ($artiste) { 
    			$permalink = str_replace('%artiste%', $artistesurname, $permalink);
    		} else {
    			$permalink = str_replace('%artiste%', 0, $permalink);
    		}
            if ($subtitle) { 
    			$permalink = str_replace('%subtitle%', $subtitle, $permalink);
    		} else {
    			$permalink = str_replace('%subtitle%', 0, $permalink);
    		}
            if ($pagenumber) { 
    			$permalink = str_replace('%numero_de_page%', $pagenumber, $permalink);
    		} else {
    			$permalink = str_replace('%numero_de_page%', 0, $permalink);
    		}
    	}
    
    	return $permalink;
    }
    add_filter('post_type_link', 'product_permalinks', 10, 3);
    

    In the backend it’s showing the change :
    permalink display in the backend

    But in frontend i get a 404. I tried on an other custom post and i get the same.
    Anyone had already the same problem ?

    Thanks in advance,

    Simon

  • What should increasing the priority to 20 change?

    From the “class-acf-field-select.php” i see that there isn’t an possibility to “disable” options.

    The select itself use the “disable” in line 318.
    if( !empty($field['disabled']) ) $select['disabled'] = 'disabled';

    the select itself is rendered via
    acf_select_input( $select );

    which is in acf-input-functions.php

    acf_get_select_input calls acf_walk_select_input($choices, $value)

    where the “option tags are rended with “value”, “selected” and “data-i” attributes.
    So no “disabled” html attribute.

    
    // single (option)	
    			} else {
    				$attrs = array(
    					'value' => $value
    				);
    				
    				// If is selected.
    				$pos = array_search( esc_attr($value), $values );
    				if( $pos !== false ) {
    					$attrs['selected'] = 'selected';
    					$attrs['data-i'] = $pos;
    				}
    				$html .= sprintf( '<option %s>%s</option>', acf_esc_attr($attrs), esc_html($label) );
    			}
    

    If there would be a way to access the form “post_id” to filter function of the field i could delete the “not wanted options” from the array when post_id is e.g. “new_post”.

  • Solved it. If anyone ever needs this here you go. My main issue was that instead of using $_POST[‘acf’][‘field_5da4981a6418e’] I used $_POST[‘acf’][‘phone_numbers’] so it wasn’t storing the values but storing NULL.

    function update_phone() {
      global $wpdb;
      $current_user_id = get_current_user_id();
    
      $new_value = $_POST['acf']['field_5da4981a6418e'];
    
      $wpdb->update(
        "custom_table",
        array(
          "phone_numbers" => $new_value,
        ),
        array( 
          'wp_user' =>  $current_user_id,
        ),
        array( 
          '%s',
        ),
        array( '%s' )
      );
    }
    add_action('acf/save_post', 'update_phone', 1);
  • I found a solution, but I’m sure we can do it cleaner.

    In My theme:

    ## First I add somes helpers

    
    function zk_acf_get_field_groups_by_tax($taxonomy){
        $groups = acf_get_field_groups();
        $filtered_groups = [];
        foreach($groups as $key => $group):
            foreach($group['location'] as $location):
                foreach($location as $location_item){
                    if(
                        $location_item['param'] == 'taxonomy' && 
                        $location_item['operator'] == '==' &&
                        $location_item['value'] == $taxonomy
                    ){
                        $filtered_groups[] = $group;
                    }
                }
            endforeach;
        endforeach;
        return $filtered_groups;
    }
    
    function zk_acf_get_fields_by_tax($taxonomy){
        $groups = zk_acf_get_field_groups_by_tax($taxonomy);
        $fields = [];
        foreach($groups as $group){
            $group_fields = acf_get_fields($group['key']);
            if(is_array($group_fields)){
                $fields  = array_merge($fields, $group_fields);
            }
        }
        return $fields;
    }
    

    ## Then I copy class-acf-field-taxonomy.php in my theme and modify ajax_add_term function

    
    function ajax_add_term() {
    		// vars
    		$args = wp_parse_args($_POST, array(
    			'nonce'				=> '',
    			'field_key'			=> '',
    			'term_name'			=> '',
    			'term_parent'		=> ''
    		));
    		
    		// verify nonce
    		if( !acf_verify_ajax() ) {
    			die();
    		}		
    		
    		// load field
    		$field = acf_get_field( $args['field_key'] );
    		if( !$field ) {
    			die();
    		}
    		
    		// vars
    		$taxonomy_obj = get_taxonomy($field['taxonomy']);
    		$taxonomy_label = $taxonomy_obj->labels->singular_name;
    		$custom_fields = zk_acf_get_fields_by_tax($field['taxonomy']);
    
    		// validate cap
    		// note: this situation should never occur due to condition of the add new button
    		if( !current_user_can( $taxonomy_obj->cap->manage_terms) ) {
    			wp_send_json_error(array(
    				'error'	=> sprintf( __('User unable to add new %s', 'acf'), $taxonomy_label )
    			));
    		}
    		
    		// save?
    		if( $args['term_name'] ) {
    			
    			// exists
    			if( term_exists($args['term_name'], $field['taxonomy'], $args['term_parent']) ) {
    				wp_send_json_error(array(
    					'error'	=> sprintf( __('%s already exists', 'acf'), $taxonomy_label )
    				));
    			}
    			
    			// vars
    			$extra = array();
    			if( $args['term_parent'] ) {
    				$extra['parent'] = (int) $args['term_parent'];
    			}
    			
    			// insert
    			$data = wp_insert_term( $args['term_name'], $field['taxonomy'], $extra );
                
                
                
                
    			// error
    			if( is_wp_error($data) ) {
    				wp_send_json_error(array(
    					'error'	=> $data->get_error_message()
    				));
    			}
    			
    			// load term
    			$term = get_term($data['term_id']);
    			foreach($custom_fields as $custom_field){
                    $value = $_POST[$custom_field['name']];
                    if($value){
                        update_field($custom_field['name'], $value, $term);
                    }
                }
                
    			// prepend ancenstors count to term name
    			$prefix = '';
    			$ancestors = get_ancestors( $term->term_id, $term->taxonomy );
    			if( !empty($ancestors) ) {
    				$prefix = str_repeat('- ', count($ancestors));
    			}
    		
    			// success
    			wp_send_json_success(array(
    				'message'		=> sprintf( __('%s added', 'acf'), $taxonomy_label ),
    				'term_id'		=> $term->term_id,
    				'term_name'		=> $term->name,
    				'term_label'	=> $prefix . $term->name,
    				'term_parent'	=> $term->parent
    			));
    				
    		}
    		
    		?><form method="post"><?php
    		
    		acf_render_field_wrap(array(
    			'label'			=> __('Name', 'acf'),
    			'name'			=> 'term_name',
    			'type'			=> 'text'
            ));
            
            foreach($custom_fields as $field){
               acf_render_field_wrap($field); 
                ?>
                    <script>
                        acf.add_filter('prepare_for_ajax', function (data) {
                            data['<?php echo $field['name']; ?>'] = jQuery('#acf-<?php echo $field['key']; ?>').val();
                            console.log('data',data);
                            return data;
                        });
                    </script>
                <?php
            }
           
    
    		if( is_taxonomy_hierarchical( $field['taxonomy'] ) ) {
    			
    			$choices = array();
    			$response = $this->get_ajax_query($args);
    			
    			if( $response ) {
    				
    				foreach( $response['results'] as $v ) { 
    					
    					$choices[ $v['id'] ] = $v['text'];
    					
    				}
    				
    			}
    			
    			acf_render_field_wrap(array(
    				'label'			=> __('Parent', 'acf'),
    				'name'			=> 'term_parent',
    				'type'			=> 'select',
    				'allow_null'	=> 1,
    				'ui'			=> 0,
    				'choices'		=> $choices
    			));
    			
    		}
    		
    		
    		?><p class="acf-submit">
    			<button class="acf-submit-button button button-primary" type="submit"><?php _e("Add", 'acf'); ?></button>
    		</p>
    		</form><?php
    		
    		
    		// die
    		die;	
    		
    	}
    
  • I think you’re looking for the acf/fields/flexible_content/layout_title filter. Assuming the name on that Title dropdown is just ‘title’ I think this should do it?

    
    add_filter('acf/fields/flexible_content/layout_title', function($title) {
        $ret = $title;
        if ($custom_title = get_sub_field('title')) {
            $ret = sprintf('<strong>%s</strong> <em style="font-size: 80%; opacity: 0.5">%s</em>', $custom_title, $title);
        }
    
        return $ret;
    });
    
  • On some level, I’m certainly wishing that I went the custom events section route as you tend to do. That said, for all of my programming knowledge deficiencies, I find these troubleshooting efforts incredibly addictive, and they’re the reason I’m shoulder deep in javascript training courses and the like. I truly can’t get enough of it. Anyways —

    Shot in the dark, but maybe the following could help us (in some small way) get to the bottom of this, or blaze the best alternative solution path:

    As I have hopefully made clear, “Organizers” is a native custom post type included with the Tribe plugin. So for the sake of testing and my own understanding, I moved from my functions.php over to the single organizer page template (organizer.php).

    We’ve established (or so I meant to) that the upcoming events related to the given organizer are output with echo tribe_organizer_upcoming_events( $organizer_id );

    So I added the following to the template file:

    <?php
    // tribe_get_organizers_ids() function with the event ID I've been testing on
    $test_organizer_ids = tribe_get_organizer_ids(38901);

    And this below the native echo tribe_organizer_upcoming_events( $organizer_id );:

    <?php
    		echo '<pre>';
    print_r($test_organizer_ids);
    echo '</pre>';

    Which returned the organizer IDs, but—predictably, I’m sure—only the IDs of the Organizers set via the native tribe meta field:

    Array
    (
        [0] => 16671
        [1] => 29406
        [2] => 29415
        [3] => 30056
    )

    There’s a good chance this does nothing to help you/us, but at least I can feel slightly less guilt in knowing that you know that I’m not just sitting on my hands while you provide above-and-beyond support.

    Here’s the full edited template file. Maybe the action filters provide some clue with respect to timing as well?

    <?php
    /**
     * Single Organizer Template
     * The template for an organizer. By default it displays organizer information and lists
     * events that occur with the specified organizer.
     *
     * This view contains the filters required to create an effective single organizer view.
     *
     * You can recreate an ENTIRELY new single organizer view by doing a template override, and placing
     * a Single_Organizer.php file in a tribe-events/pro/ directory within your theme directory, which
     * will override the /views/pro/single_organizer.php.
     *
     * You can use any or all filters included in this file or create your own filters in
     * your functions.php. In order to modify or extend a single filter, please see our
     * readme on templates hooks and filters (TO-DO)
     *
     * @package TribeEventsCalendarPro
     *
     * @version 4.4.28
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	die( '-1' );
    }
    
    $organizer_id = get_the_ID();
    $test_organizer_ids = tribe_get_organizer_ids(38901);
    
    ?>
    
    <?php while ( have_posts() ) : the_post(); ?>
    	<div class="tribe-events-organizer">
    			<p class="tribe-events-back">
    				<a href="<?php echo esc_url( tribe_get_events_link() ); ?>" rel="bookmark"><?php printf( __( '&larr; Back to %s', 'tribe-events-calendar-pro' ), tribe_get_event_label_plural() ); ?></a>
    			</p>
    
    		<?php do_action( 'tribe_events_single_organizer_before_organizer' ) ?>
    		<div class="tribe-events-organizer-meta tribe-clearfix">
    
    				<!-- Organizer Title -->
    				<?php do_action( 'tribe_events_single_organizer_before_title' ) ?>
    				<h1 class="tribe-organizer-name"><?php echo tribe_get_organizer( $organizer_id ); ?></h1>
    				<?php do_action( 'tribe_events_single_organizer_after_title' ) ?>
    
    				<!-- Organizer Meta -->
    				<?php do_action( 'tribe_events_single_organizer_before_the_meta' ); ?>
    				<?php echo tribe_get_organizer_details(); ?>
    				<?php do_action( 'tribe_events_single_organizer_after_the_meta' ) ?>
    
    				<!-- Organizer Featured Image -->
    				<?php echo tribe_event_featured_image( null, 'full' ) ?>
    
    				<!-- Organizer Content -->
    				<?php if ( get_the_content() ) { ?>
    				<div class="tribe-organizer-description tribe-events-content">
    					<?php the_content(); ?>
    				</div>
    				<?php } ?>
    
    			</div>
    			<!-- .tribe-events-organizer-meta -->
    		<?php do_action( 'tribe_events_single_organizer_after_organizer' ) ?>
    
    		<!-- Upcoming event list -->
    		<?php do_action( 'tribe_events_single_organizer_before_upcoming_events' ) ?>
    
    		<?php
    		// Use the tribe_events_single_organizer_posts_per_page to filter the number of events to get here.
    		echo tribe_organizer_upcoming_events( $organizer_id );
    		echo '<pre>';
    print_r($test_organizer_ids);
    echo '</pre>';
    		 ?>
    
    		<?php do_action( 'tribe_events_single_organizer_after_upcoming_events' ) ?>
    
    	</div><!-- .tribe-events-organizer -->
    	<?php
    	do_action( 'tribe_events_single_organizer_after_template' );
    endwhile;
  • Thanks John,

    I understand, and sincerely appreciate you taking the time to respond at all nonetheless.

    Unfortunately, the Tribe support staff has consistently proven quite eager to avoid providing any assistance said to fall beyond their “Scope of Support.” This was the gist of their response —

    I did look at your PHP file and it looks very similar (other than ACF logic) to what The Events Calendar is already doing: https://github.com/moderntribe/the-events-calendar/blob/4.9.1.1/src/Tribe/Query.php#L455-L461

    I’m not personally very familiar with ACF, but I know their codebase has received significant updates in recent history so maybe their logic isn’t as it used to be.

    If any easier, would it be possible to help me write a standalone query, for placement within the Tribe single-organizer.php template (pasted below), instead? Like the native tribe_organizer_upcoming_events function, the idea——in theory——would be for it to find any Tribe single event post where the organizer ID was added to the event meta, and return each given event ID.

    In other words, it would look for any Tribe event where the given organizer ID is selected via the ACF Pro field “the_organizers”.

    I’ve also included a link to a screenshot for additional reference, plus a few potentially relevant example links, below:

    Screenshot

    Single Event Page

    Speaker | Organizer Page
    (set by native Tribe field–upcoming event display)

    Speaker | Organizer Page
    (set by ACF relational object field–upcoming event not display)

    <?php
    /**
     * Single Organizer Template
     * The template for an organizer. By default it displays organizer information and lists
     * events that occur with the specified organizer.
     *
     * This view contains the filters required to create an effective single organizer view.
     *
     * You can recreate an ENTIRELY new single organizer view by doing a template override, and placing
     * a Single_Organizer.php file in a tribe-events/pro/ directory within your theme directory, which
     * will override the /views/pro/single_organizer.php.
     *
     * You can use any or all filters included in this file or create your own filters in
     * your functions.php. In order to modify or extend a single filter, please see our
     * readme on templates hooks and filters (TO-DO)
     *
     * @package TribeEventsCalendarPro
     *
     * @version 4.4.28
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	die( '-1' );
    }
    
    $organizer_id = get_the_ID();
    ?>
    
    <?php while ( have_posts() ) : the_post(); ?>
    	<div class="tribe-events-organizer">
    			<p class="tribe-events-back">
    				<a href="<?php echo esc_url( tribe_get_events_link() ); ?>" rel="bookmark"><?php printf( __( '&larr; Back to %s', 'tribe-events-calendar-pro' ), tribe_get_event_label_plural() ); ?></a>
    			</p>
    
    		<?php do_action( 'tribe_events_single_organizer_before_organizer' ) ?>
    		<div class="tribe-events-organizer-meta tribe-clearfix">
    
    				<!-- Organizer Title -->
    				<?php do_action( 'tribe_events_single_organizer_before_title' ) ?>
    				<h1 class="tribe-organizer-name"><?php echo tribe_get_organizer( $organizer_id ); ?></h1>
    				<?php do_action( 'tribe_events_single_organizer_after_title' ) ?>
    
    				<!-- Organizer Meta -->
    				<?php do_action( 'tribe_events_single_organizer_before_the_meta' ); ?>
    				<?php echo tribe_get_organizer_details(); ?>
    				<?php do_action( 'tribe_events_single_organizer_after_the_meta' ) ?>
    
    				<!-- Organizer Featured Image -->
    				<?php echo tribe_event_featured_image( null, 'full' ) ?>
    
    				<!-- Organizer Content -->
    				<?php if ( get_the_content() ) { ?>
    				<div class="tribe-organizer-description tribe-events-content">
    					<?php the_content(); ?>
    				</div>
    				<?php } ?>
    
    			</div>
    			<!-- .tribe-events-organizer-meta -->
    		<?php do_action( 'tribe_events_single_organizer_after_organizer' ) ?>
    
    		<!-- Upcoming event list -->
    		<?php do_action( 'tribe_events_single_organizer_before_upcoming_events' ) ?>
    
    		<?php
    		// Use the tribe_events_single_organizer_posts_per_page to filter the number of events to get here.
    		echo tribe_organizer_upcoming_events( $organizer_id ); ?>
    
    		<?php do_action( 'tribe_events_single_organizer_after_upcoming_events' ) ?>
    
    	</div><!-- .tribe-events-organizer -->
    	<?php
    	do_action( 'tribe_events_single_organizer_after_template' );
    endwhile;
  • Thanks John,

    I understand, and sincerely appreciate you taking the time to respond at all nonetheless.

    Unfortunately, the Tribe support staff has consistently proven quite eager to avoid providing any assistance said to fall beyond their “Scope of Support.” This was the gist of their response —

    I did look at your PHP file and it looks very similar (other than ACF logic) to what The Events Calendar is already doing: https://github.com/moderntribe/the-events-calendar/blob/4.9.1.1/src/Tribe/Query.php#L455-L461

    I’m not personally very familiar with ACF, but I know their codebase has received significant updates in recent history so maybe their logic isn’t as it used to be.

    If any easier, would it be possible to help me write a standalone query, for placement within the Tribe single-organizer.php template (both attached and pasted below), instead? Like the native tribe_organizer_upcoming_events function, the idea——in theory——would be for it to find any Tribe single event post where the organizer ID was added to the event meta, and return each given event ID.

    In other words, it would look for any Tribe event where the given organizer ID is selected via the ACF Pro field “the_organizers”.

    I’ve also attached a detailed screenshot for additional reference, as well as a few potentially relevant example links:

    Single Event Page

    Speaker | Organizer Page
    (set by native Tribe field–upcoming event display)

    Speaker | Organizer Page
    (set by ACF relational object field–upcoming event not display)

    <?php
    /**
     * Single Organizer Template
     * The template for an organizer. By default it displays organizer information and lists
     * events that occur with the specified organizer.
     *
     * This view contains the filters required to create an effective single organizer view.
     *
     * You can recreate an ENTIRELY new single organizer view by doing a template override, and placing
     * a Single_Organizer.php file in a tribe-events/pro/ directory within your theme directory, which
     * will override the /views/pro/single_organizer.php.
     *
     * You can use any or all filters included in this file or create your own filters in
     * your functions.php. In order to modify or extend a single filter, please see our
     * readme on templates hooks and filters (TO-DO)
     *
     * @package TribeEventsCalendarPro
     *
     * @version 4.4.28
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	die( '-1' );
    }
    
    $organizer_id = get_the_ID();
    ?>
    
    <?php while ( have_posts() ) : the_post(); ?>
    	<div class="tribe-events-organizer">
    			<p class="tribe-events-back">
    				<a href="<?php echo esc_url( tribe_get_events_link() ); ?>" rel="bookmark"><?php printf( __( '&larr; Back to %s', 'tribe-events-calendar-pro' ), tribe_get_event_label_plural() ); ?></a>
    			</p>
    
    		<?php do_action( 'tribe_events_single_organizer_before_organizer' ) ?>
    		<div class="tribe-events-organizer-meta tribe-clearfix">
    
    				<!-- Organizer Title -->
    				<?php do_action( 'tribe_events_single_organizer_before_title' ) ?>
    				<h1 class="tribe-organizer-name"><?php echo tribe_get_organizer( $organizer_id ); ?></h1>
    				<?php do_action( 'tribe_events_single_organizer_after_title' ) ?>
    
    				<!-- Organizer Meta -->
    				<?php do_action( 'tribe_events_single_organizer_before_the_meta' ); ?>
    				<?php echo tribe_get_organizer_details(); ?>
    				<?php do_action( 'tribe_events_single_organizer_after_the_meta' ) ?>
    
    				<!-- Organizer Featured Image -->
    				<?php echo tribe_event_featured_image( null, 'full' ) ?>
    
    				<!-- Organizer Content -->
    				<?php if ( get_the_content() ) { ?>
    				<div class="tribe-organizer-description tribe-events-content">
    					<?php the_content(); ?>
    				</div>
    				<?php } ?>
    
    			</div>
    			<!-- .tribe-events-organizer-meta -->
    		<?php do_action( 'tribe_events_single_organizer_after_organizer' ) ?>
    
    		<!-- Upcoming event list -->
    		<?php do_action( 'tribe_events_single_organizer_before_upcoming_events' ) ?>
    
    		<?php
    		// Use the tribe_events_single_organizer_posts_per_page to filter the number of events to get here.
    		echo tribe_organizer_upcoming_events( $organizer_id ); ?>
    
    		<?php do_action( 'tribe_events_single_organizer_after_upcoming_events' ) ?>
    
    	</div><!-- .tribe-events-organizer -->
    	<?php
    	do_action( 'tribe_events_single_organizer_after_template' );
    endwhile;
  • Thanks John,

    I understand, and sincerely appreciate you taking the time to respond at all nonetheless.

    Unfortunately, the Tribe support staff has consistently proven quite eager to avoid providing any assistance said to fall beyond their “Scope of Support.” This was the gist of their response —

    I did look at your PHP file and it looks very similar (other than ACF logic) to what The Events Calendar is already doing: https://github.com/moderntribe/the-events-calendar/blob/4.9.1.1/src/Tribe/Query.php#L455-L461

    I’m not personally very familiar with ACF, but I know their codebase has received significant updates in recent history so maybe their logic isn’t as it used to be.

    If any easier, would it be possible to help me write a standalone query, for placement within the Tribe single-organizer.php template (both attached and pasted below), instead? Like the native tribe_organizer_upcoming_events function, the idea——in theory——would be for it to find any Tribe single event post where the organizer ID was added to the event meta, and return each given event ID.

    In other words, it would look for any Tribe event where the given organizer ID is selected via the ACF Pro field “the_organizers”.

    I’ve also attached a detailed screenshot for additional reference, as well as a few potentially relevant example links:

    Single Event Page

    Speaker | Organizer Page
    (set by native Tribe field–upcoming event display)

    Speaker | Organizer Page
    (set by ACF relational object field–upcoming event not display)

    <?php
    /**
     * Single Organizer Template
     * The template for an organizer. By default it displays organizer information and lists
     * events that occur with the specified organizer.
     *
     * This view contains the filters required to create an effective single organizer view.
     *
     * You can recreate an ENTIRELY new single organizer view by doing a template override, and placing
     * a Single_Organizer.php file in a tribe-events/pro/ directory within your theme directory, which
     * will override the /views/pro/single_organizer.php.
     *
     * You can use any or all filters included in this file or create your own filters in
     * your functions.php. In order to modify or extend a single filter, please see our
     * readme on templates hooks and filters (TO-DO)
     *
     * @package TribeEventsCalendarPro
     *
     * @version 4.4.28
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	die( '-1' );
    }
    
    $organizer_id = get_the_ID();
    ?>
    
    <?php while ( have_posts() ) : the_post(); ?>
    	<div class="tribe-events-organizer">
    			<p class="tribe-events-back">
    				<a href="<?php echo esc_url( tribe_get_events_link() ); ?>" rel="bookmark"><?php printf( __( '&larr; Back to %s', 'tribe-events-calendar-pro' ), tribe_get_event_label_plural() ); ?></a>
    			</p>
    
    		<?php do_action( 'tribe_events_single_organizer_before_organizer' ) ?>
    		<div class="tribe-events-organizer-meta tribe-clearfix">
    
    				<!-- Organizer Title -->
    				<?php do_action( 'tribe_events_single_organizer_before_title' ) ?>
    				<h1 class="tribe-organizer-name"><?php echo tribe_get_organizer( $organizer_id ); ?></h1>
    				<?php do_action( 'tribe_events_single_organizer_after_title' ) ?>
    
    				<!-- Organizer Meta -->
    				<?php do_action( 'tribe_events_single_organizer_before_the_meta' ); ?>
    				<?php echo tribe_get_organizer_details(); ?>
    				<?php do_action( 'tribe_events_single_organizer_after_the_meta' ) ?>
    
    				<!-- Organizer Featured Image -->
    				<?php echo tribe_event_featured_image( null, 'full' ) ?>
    
    				<!-- Organizer Content -->
    				<?php if ( get_the_content() ) { ?>
    				<div class="tribe-organizer-description tribe-events-content">
    					<?php the_content(); ?>
    				</div>
    				<?php } ?>
    
    			</div>
    			<!-- .tribe-events-organizer-meta -->
    		<?php do_action( 'tribe_events_single_organizer_after_organizer' ) ?>
    
    		<!-- Upcoming event list -->
    		<?php do_action( 'tribe_events_single_organizer_before_upcoming_events' ) ?>
    
    		<?php
    		// Use the tribe_events_single_organizer_posts_per_page to filter the number of events to get here.
    		echo tribe_organizer_upcoming_events( $organizer_id ); ?>
    
    		<?php do_action( 'tribe_events_single_organizer_after_upcoming_events' ) ?>
    
    	</div><!-- .tribe-events-organizer -->
    	<?php
    	do_action( 'tribe_events_single_organizer_after_template' );
    endwhile;
  • Aaand 10 months later I stumbled on this bug again.

    I’m registering fields dynamically:

    
    foreach( $levels as $i => $level ) {
        $name = "level_{$level->term_id}_winner";
    
        acf_add_local_field([
            'parent'        => 'group_5cb57c19cffde',
            'key'           => "field_{$name}",
            'label'         => sprintf( __( '%s level winner', 'imatch' ), $level->name ),
            'name'          => $name,
            'type'          => 'post_object',
            'post_type'     => [ 'im_registration' ],
            'taxonomy'      => [],
            'allow_null'    => true,
            'return_format' => 'id',
        ]);
    }
    
  • This is a pretty heavy-handed ‘solution’ but, for what it’s worth, what I’m doing at the moment to remove unused ACF post_meta data is this…

    I name all my ACF fields with a unique prefix (eg. my_prefix_first_name, my_prefix_last_name, etc…) making sure that my_prefix is unlikely to conflict with any default WordPress post_meta keys or any of the post_meta keys created by plugins that I might use.

    Then, every time I update a post, I simply delete ALL post_meta containing my_prefix using the acf/save_post action below:

    function acf_delete_all_post_meta($post_id) {
        global $wpdb;
        $result = $wpdb->query($wpdb->prepare("
            DELETE FROM wp_postmeta
            WHERE meta_key
            LIKE '%my_prefix%'
            AND wp_postmeta.post_id = %s",
            $post_id
        ));
    }
    add_action('acf/save_post', 'acf_delete_all_post_meta', 1);

    With a priority of less than 10, this action will fire BEFORE the actual post data is saved. Thus, when the post data IS saved, it’s saved to a clean slate and only saves post_meta for fields that are currently being used in the post.

    Obviously, this technique will not flush your entire site of unwanted post_meta in one go – it only acts upon one post at a time and only when you update the post. However, if used during development (which is probably the only time I would use it) it will help tidy-things-up as you go along.

  • Another way to accomplish this is to use the global variable $_SESSION to store whatever you want the notice to be. I wrote a PHP class and wrapper function to keep track of the notices so you don’t have to write to the database.

    <?php
    
    /**
     *	Class to handle admin notices
     *
     */
    
    class BricNotices {
    	
    	
    	public function __construct() {
    		
    		//Start the session
    		add_action( 'admin_init', [ $this, 'start_session' ] );
    		
    		add_action( 'admin_notices', [ $this, 'display_notices' ] );
    		
    	}
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	/**
    	 *		Add a notice
    	 *
    	 *
    	 */
    	
    	
    	public function add_notice( $text = '', $type = 'success' ) {
    		
    		
    		
    		$_SESSION['bric_notices'][] = [
    			'type' => $type,
    			'text' => $text,
    		];
    		
    		
    		
    	}
    		
    	
    	
    	
    	/**
    	 *		Display the notices
    	 *
    	 *
    	 */
    	
    	public function display_notices() {
    		
    		
    		if ( !isset( $_SESSION['bric_notices'] ) &&  empty( $_SESSION['bric_notices'] ) ) {
    			
    			return;
    			
    		}
    		
    		
    		if ( is_array( $_SESSION['bric_notices'] ) ) {
    			
    			foreach ( $_SESSION['bric_notices'] as $this->notice ) {
    				
    				$this->print_notice();
    				
    				
    			}
    		
    				
    			
    		}
    		
    		
    		
    		//Delete the notices
    		unset( $_SESSION[ 'bric_notices' ] );
    		
    	}
    	
    	
    	
    	
    	
    	
    	private function print_notice() {
    		
    		
    		//notice types = error, warning, success, info
    		
    		
    		printf( '<div class="notice notice-%s is-dismissible"><p>%s</p></div>', $this->notice['type'], $this->notice['text'] );
    
    				
    		
    	}
    	
    	
    	
    	
    	
    	
    	/**
    	 *		Enable the use of the global $_SESSION variable
    	 *
    	 *
    	 *
    	 */	
    		
    		
    	public function start_session() {
    		
    		if ( !isset( $_SESSION )) {
    			session_start();			
    		}
    		
    
    			
    	}
    	
    		
    		
    		
    		
    		
    		
    		
    		
    	
    	
    	
    	
    	
    }
    
    global $BricNotices;
    $BricNotices = new BricNotices();
    
    function add_bric_notice( $text = '', $type = 'success' ) {
    	
    	global $BricNotices;
    		
    	$BricNotices->add_notice( $text, $type );
    	
    }
    
  • When editing, the ID comes form the url (REQUEST) and the invented ID disappears when the post is saved with its real new id.

    I’d still be glad with a more elegant solution.
    How could I let wp create a new ID itself before the post is saved or even exists?

    here is the complete code of this function:

    add_filter('acf/validate_value/name=fld_pubdoi_doinumber', 'acf_unique_value_field_pubs', 10, 4);
    add_filter('acf/validate_value/name='.$field_name, 'acf_unique_value_field_pubs', 10, 4);
    function acf_unique_value_field_pubs($valid, $value, $field, $input) {
    
        if (!$valid ) {
          return $valid;
        }
       
        if (isset($_POST['post_ID'])) {
            $post_id = intval($_POST['post_ID']);
        } elseif (isset($_POST['post_id'])) {
            $post_id = intval($_POST['post_id']);
        } elseif (isset($_REQUEST['item_id'])) {//IIQINST ONLY
            $post_id = intval($_REQUEST['item_id']);
        } else {
            $post_id = intval('9999999999999999');
        }
    
        //$post_type = get_post_type($post_id);
        $post_type = 'pt_publicacoes_doi';
        $field_name = $field['name'];
    
        $args = array(
          'post_type' => $post_type,
          'post_status' => 'publish, draft',
          'post__not_in' => array($post_id),
          'meta_query' => array(
            array(
              'key' => $field_name,
              'value' => $value
            )
          )
        );
        $query = new WP_Query($args);
     
            if( $query->have_posts() ) {
                $query->the_post();
                $another_post_id = get_the_ID();
            }
    
            if (count($query->posts)){
              return $field['label'].' already exists';
            }
    
            return true;
    
    }

    And the form args:

    
    $item_id = ( isset($_GET['item_id']) ) ? $_GET['item_id'] : 'new_post';
    
    acf_form(array(
            'id' => 'iiq-addedit-pub-form',
            'post_id'       => $item_id,
            'post_title'    => false,
            'post_content'  => false,
            'form_attributes' => array(),
            'submit_value' => __('SAVE', 'acf'),
            'html_submit_button'    => '<input type="submit" class="but-form" value="%s" />',
            'new_post'      => array(
                'post_type'     => 'pt_publicacoes_doi',
                'post_status'   => "publish"
            ),
            'updated_message' => __($text_return, 'acf'),
            'html_updated_message'  => '<div id="adm-message" class="updated"><p>%s</p></div>',
            'return' => $return_url,
          
        ));
  • Hey, care to share the code you used to actually set custom pin? I have a similar case, although I call entire group of fields on my page.php like that

    <?php
    
                    acf_form(array(
                        'post_id'		=> 'new_post',
                        'field_groups'  => array( 72 ),
                        'new_post'		=> array(
                            'post_type'	=> 'post',
                            'post_status'	=> 'publish',
                        ),
                        'submit_value'          => '[+] Send',
                        'return'                => '/',
                        'html_submit_button'    =>  '<input type="submit" id="addsignal" value="%s" />'
                    ));
    
                    ?>

    … and I’m really stuck on how to pass custom pin parameters. Thanks.

  • That code is working fine. For example when I use the short code I use:

    [acf_repeater field="inventory-8" post_id="32063" sub_fields="system"]
    %system%[/acf_repeater]

    That code displays all the repeater fields of that specific post id with that subfield.

    But how can I get it to display only 1 row?

  • That code is working fine. For example when I use the short code I use:

    [acf_repeater field="inventory-8" post_id="32063" sub_fields="system"]
    %system%[/acf_repeater]

    That code displays all the repeater fields of that specific post id with that subfield.

    But how can I get it to display only 1 row?

  • Thank you very much! I did a slight modification in order to be able to retrieve the name or the field key depending what is given, because I needed the exact opposite. I paste it here for future reference to others. Cheers!

    function acf_get_field_info( $return = 'name', $field_key, $post_id ) {
    		global $wpdb;
    		//choose name 
    		if($return == 'name'){
    			$acf_fields = $wpdb->get_results( $wpdb->prepare( "SELECT ID,post_parent,post_excerpt FROM $wpdb->posts WHERE post_name=%s AND post_type=%s" , $field_key , 'acf-field' ) );
    		}elseif($return == 'key'){
    			$acf_fields = $wpdb->get_results( $wpdb->prepare( "SELECT ID,post_parent,post_name FROM $wpdb->posts WHERE post_excerpt=%s AND post_type=%s" , $field_key , 'acf-field' ) );
    		}
    		// get all fields with that name.
    		switch ( count( $acf_fields ) ) {
    			case 0: // no such field
    				return false;
    			case 1: // just one result.
    				return $acf_fields[0]->post_excerpt;
    		}
    		// result is ambiguous
    		// get IDs of all field groups for this post
    		$field_groups_ids = array();
    		$field_groups = acf_get_field_groups( array(
    			'post_id' => $post_id,
    		) );
    		foreach ( $field_groups as $field_group )
    			$field_groups_ids[] = $field_group['ID'];
    
    		// Check if field is part of one of the field groups
    		// Return the first one.
    		foreach ( $acf_fields as $acf_field ) {
    			if ( in_array($acf_field->post_parent,$field_groups_ids) )
    				return $acf_field->post_name;
    		}
    		return false;
    	}
  • Then your query is correct. But if you want to query individual artists, you have to use a single-artists.php.

    Another tip: If you name your variable $works and not $posts then it’s easier to read:

    <?php 
    
    $works = get_field( 'featured_works' );
    
    if( $works ):
    
    foreach( $works as $work ):
    
    echo get_the_permalink( $work->ID );
    
    endforeach;
    
    else:
    
    echo sprintf( '<p>%s</p>', __('No work here...') );
    
    endif;

    In your field ‘featured_works’ you have an object with work?

  • I see what you are saying, but I thought it defaulted to the current post ID. Anyway, my fields are being populated now, whether I add a varible to the ‘post_ID’ or leave it as ‘false’.
    The only fields that are not functioning properly are two post object fields in a group. I have tested that group on the form, but commented them out for now. They only display the value that has been selected on the backend.

    	$post_ID = get_the_ID();
    
    	$settings = array(
    
    	'id' => 'acf-form',
    	'post_id' => $post_ID,
    	'new_post' => false,
    	'field_groups' => array('group_56f97a1203bfe','group_58b8b6b885fbb'), //'group_57180f67b48be',
    //	'fields' => array(),
    	'post_title' => false,
    	'post_content' => false,
    	'form' => true,
    	/* (array) An array or HTML attributes for the form element */
    //	'form_attributes' => array(),
    	'return' => '',
    	'html_before_fields' => '',
    	'html_after_fields' => '',
    	'submit_value' => __("Update", 'acf'),
    	'updated_message' => __("Post updated", 'acf'),
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'field_el' => 'div',
    	'uploader' => 'wp',
    	'honeypot' => true,
    	'html_updated_message'	=> '<div id="message" class="updated"><p>%s</p></div>',
    	'html_submit_button'	=> '<input type="submit" class="acf-button button button-primary button-large" value="%s" />',
    	'html_submit_spinner'	=> '<span class="acf-spinner"></span>'
    			
    );
    	
    		acf_form($settings);
  • This one is a bit old but I just came across the need to do this. I don’t exclude videos, but I like to exclude PNGs and TIFFs on Image fields because their file sizes can be wildly large. Here’s how I do it:

    
    function prevent_certain_image_uploads($errors, $file, $attachment, $field, $context) {
    	$disallowed_formats = array('png', 'tiff');
    	if(in_array(strtolower($file['type']), $disallowed_formats)) {
    		$errors['mime_types'] = sprintf(__('File type may not be %s.', 'acf'), strtoupper($file['type']));
    	}
    	return $errors;
    }
    add_filter('acf/validate_attachment/type=image', __NAMESPACE__.'\\prevent_certain_image_uploads', 10, 5);
    

    It’s pretty easy to adapt this to your use case, just add the file extensions you want to exclude to the $disallowed_formats array and you should be good to go!

Viewing 25 results - 76 through 100 (of 180 total)