Support

Account

Forum Replies Created

  • Example for JS:

    (function( $ ) {
    	'use strict';
    
    		acf.add_filter('date_picker_args', function(args, el) {
    			args.yearRange = "-1000:+50";
    			return args;
    		});
    
    })( jQuery );
  • It works great. FYI for future visitors. The JS must be added AFTER acf-input is added. And example could be:

    wp_enqueue_script( get_stylesheet_directory_uri() . 'js/yourfile.js', array( 'jquery', 'acf-input' ), '1.0', false );

  • Hi John, thanks for this. It looks like what I’m looking for. Question: Is this filter only available with the pro version? I have a license ready but it would be the only reason to use the pro version 😉 Thanks Sascha

  • Hi John,
    I’m using a checkbox. But the main issue I found over the weekend seems to be, that I hook into post transition status. That seems to fire PRIOR to saving fields. So, the check I do in “sendPublishNewseletter” -> “if(get_field(“send_newsletter”,$postid))” first of all is only true, if the checkbox was saved before. So I guess the “update_field(“send_newsletter”,0,$postid);” function does nothing, as it does not save to the database???

    See my full code below.

    Thanks Sascha

    P.S.: I try to send a newsletter out, when the post is published. This is done by the “do_action(news_publish)” found later in the code.

    
    /* Add Newsletter Action Hook on Publish */
    add_action('transition_post_status', 'send_new_post', 10, 3);
    // Listen for publishing of a new post
    function send_new_post($new_status, $old_status, $post) {
      if('publish' === $new_status && 'publish' !== $old_status && $post->post_type === 'post') {
        sendPublishNewseletter($post->ID);
      }
    }
    //sending function
    function sendPublishNewseletter($postid){
    	if(get_field("send_newsletter",$postid)){
    		//uncheck field
    		update_field("send_newsletter",0,$postid);
    		
    		//define post ID
    		$sendoutID = $postid;
    		//get files
    		$downloadHTML ='';
    		if(get_field("dateien",$sendoutID)) { 
    				$downloadHTML .= '<div style="margin: 20px; border: 1px solid #000; border-radius: 3px; background-color: #ECECEC;"><div style="margin: 20px; "><h3>Dokumente zum Download</h3>';
    				foreach(get_field("dateien",$sendoutID) as $singleFile) {
    					$thumbnailURL = '/wp-includes/images/media/document.png';
    					$downloadHTML .= '<a href="'.$singleFile['datei']['url'].'" class="textlink" download>'.$singleFile['datei']['title'].' ('.pathinfo($singleFile['datei']['url'],PATHINFO_EXTENSION).', '.size_format($singleFile['datei']['filesize']).')</a><br/>';
    				}
    				$downloadHTML .= '</div></div>';
    			}
    		
            do_action( 'news_publish','', array( 
    			'teaser-subject' => '{post_title:'.$sendoutID.'}',
    			'teaser-date' => get_the_date( 'd.m.Y', $sendoutID ),
    			'teaser-image' => get_the_post_thumbnail_url($sendoutID),
    			'teaser-link' => '{post_link:'.$sendoutID.'}',
    			'teaser-content' => '{post_content:'.$sendoutID.'}',
    			'teaser-downloads' => '<div style="text-align: center;">'.$downloadHTML.'</div>',
    			
    		));
    	}
    }
    
  • Hi guys, John’s answer send me in the right direction. I did what the user benjibee said in that thread. It is totally fine for me to generate the keys on save and not on adding a new repeater! Thanks guys 😉

  • Great stuff Austin. This is exactly what I was looking for!!! 🙂

    Thank you very much!

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