Home Forums Front-end Issues Editing the Content of Password Protected Posts using ACF


Editing the Content of Password Protected Posts using ACF

  • Hi
    I wanted to change My “Password Protected” post’s default subject line to be changed and enter different content for each posts. That’s why I installed ACF and created a “Wysiwyg Editor” where I can add my custom content.

    Now, on my functions.php file, I added the following code:


    add_filter( 'the_password_form', 'custom_password_form' );
    function custom_password_form() {
        global $post;
        $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
        $o = '<form class="protected-post-form" action="' . get_option('siteurl') . '/wp-pass.php" method="post">
        ' . __( "<?php the_field('password_protected_post_special_content'); ?>" ) . '
        <label class="pass-label" for="' . $label . '">' . __( "Enter Your Password Here:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" style="background: #ffffff; border:1px solid #999; color:#333333; padding:10px;margin:15px auto;" size="20" /><input type="submit" name="Submit" class="button" value="' . esc_attr__( "Submit" ) . '" />
        return $o;


    As u see, I put this field “<?php the_field(‘password_protected_post_special_content’); ?>” to show the editor contents on the post. But, it is not showing up on the post. Here is a screenshot:

    Did I do anything wrong?

  • You need to use acf_form() on the front end of the site You would also show the acf form after the user submitted their password inside an if statement that only displays the form if the user has entered the correct password

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Editing the Content of Password Protected Posts using ACF’ is closed to new replies.