Support

Account

Home Forums Backend Issues (wp-admin) Custom location rules for attachment modals Reply To: Custom location rules for attachment modals

  • I’ve had the same problem myself. I was looking for a way to only show fields when the attachment was an image. Unfortunately I was never able to do so. What I did was I set my acf/location/rule_match/attachment filter to output information to a file. I tried outputting everything I could think of to this file to see if there was anything that would tell me the post id or any useful information so that I could show the images on the WP modals with no luck.

    Anyway, if someone else would like to try this and see if they can come up with anything that I missed, this is the code I put into my filter, if outputs stuff into a txt file in the same folder as the file with the function in it.

    
    
      add_filter('acf/location/rule_match/attachment', array($this, 'match_attachment_image'), 20, 3);
      function match_attachment_image($match, $rule, $options) {
        
        global $post;
        
        $file = dirname(__FILE__).'/output.txt';
        if (($handle = fopen($file, 'a')) !== false) {
          ob_start();
          echo "\r\n",'$match = '; var_dump($match);
          echo "\r\n",'$rule = '; var_dump($rule);
          echo "\r\n",'$options = '; var_dump($options);
          echo "\r\n",'$post = '; var_dump($post);
          echo "\r\n".'$_POST = '; var_dump($_POST);
          echo "\r\n".'$_GET = '; var_dump($_GET);
          fwrite($handle, ob_get_clean());
          fclose($handle);
        }
        return $match;
      }