Support

Account

Home Forums ACF PRO Media fields dissapear when using posts_where and posts_join Reply To: Media fields dissapear when using posts_where and posts_join

  • The media grid layout works differently than other things in WP. I’ve had trouble with it myself. It has to do with it being a modal window…. I never did get my problems worked out.

    My suggestion would be to use error_log() to output some stuff into the error log so you can see what’s happening and why.

    Turn on the error log in wp-config.php

    
    define('WP_DEBUG', true );
    define('WP_DEBUG_DISPLAY', false);
    define('WP_DEBUG_LOG', true);
    

    then do something like this

    
    function filter_where( $where ) {
    global $current_user;
    global $wpdb;
    	if( is_user_logged_in() && is_admin()){
    		if( isset( $_POST['action'] ) ){
    			if( $_POST['action'] == 'query-attachments' ){
    				$where .= " AND (($wpdb->postmeta.meta_key = 'mediatoegang' AND $wpdb->postmeta.meta_value LIKE '%administrator%')) ";
    			}
    		}
    	}
    	// write where to error log
    	error_log($where);
    	return $where;
    }
    add_filter('posts_where', 'filter_where');
    

    then you can look into the error log and see what you put there. You can also log other things to find out what’s going on.