Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Same. Please advise.

    Thread Starter jeffreykarbowski

    (@jeffreykarbowski)

    Nevermind, I figured this out, thanks so much for you efforts and wonderful extension to ACF!

    Thread Starter jeffreykarbowski

    (@jeffreykarbowski)

    Thanks, that was an issue, but only because when I copied over the code here I mistakenly didn’t change both action function names. I did however figure out the issue with the 400 error, it was that I was including the function only on the post.php edit page, it also needed to be included while doing ajax. (|| wp_doing_ajax()), and I am now getting a response.

    I am now having issues with getting the response to the success callback.
    Here is the code I have:

    function acfe_buttons_ajax() {
    	ob_start();
    	echo 'Results';
    	$result = ob_get_contents();
        ob_end_clean();
        return $result;
        wp_die();
    }
    add_action('wp_ajax_acfe/fields/button', 'acfe_buttons_ajax');
    add_action('wp_ajax_nopriv_acfe/fields/button', 'acfe_buttons_ajax');

    and:

    
    acf.addAction('acfe/fields/button/ajax_success', function(response, $el){
    		alert(response);
    });

    The js does the alert, but just alerts “0”. Any thoughts?

    The .js is enqueued in functions.php like:

    function agency_enqueue($hook) {
        if ( 'post.php' != $hook ) {
            return;
        }
        wp_enqueue_script( 'agency_js', get_stylesheet_directory_uri() . '/js/admin-agency.js', array('jquery'), null, true );
    }
    add_action( 'admin_enqueue_scripts', 'agency_enqueue' );

    I am also looking for this functionality, seems like it should protect PDFs automatically whether or not you are upload to the Media Library, or uploading to a page. Any clues would be appreciated, Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)