Support

Account

Home Forums Front-end Issues Post status as protected with ACF Field Reply To: Post status as protected with ACF Field

  • There is not option for this built into acf.

    You would need to create your own fields and then create an acf/save_post filter to update the post status and set the password.

    
    add_filter('acf/save_post', 'set_password_from_acf', 20);
    function set_password_from_acf($post_id) {
      $post = get_post($post_id);
      $post->post_password = get_field('pasword_field', $post_id);
      remove_filter('acf/save_post', 'set_password_from_acf', 20);
      wp_update_post($post);
      add_filter('acf/save_post', 'set_password_from_acf', 20);
    }