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);
}
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.