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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.