Support

Account

Home Forums Backend Issues (wp-admin) Change post featured image based on user status Reply To: Change post featured image based on user status

  • @hube2 John,

    your solution gave me right direction !!

    for anyone looking for the same or similiar solution here is the code

    add_filter('post_thumbnail_id', 'replace_thumbnail_id_with_acf', 20, 2);
    function replace_thumbnail_id_with_acf($thumbnail_id, $post) {
    
    if ( is_user_logged_in() ) {
        $image_id = get_field('reveal_face', $post->ID, false);
        if ($image_id) {
          $thumbnail_id = $image_id;
        }
    } else {
        $image_id = get_field('_thumbnail_id', $post->ID, false);
        if ($image_id) {
          $thumbnail_id = $image_id;
        }
    }
    return $thumbnail_id;
    }