• Hello,

    I am having issues when trying to modify the password protected post texts in this otherwise fantastic theme.
    So basically, I am building a website in french which will have a few articles and pages protected with a password. By default the text when requiring password is in English, and I would like to change that to French.

    I am using a child theme, but I can’t get my new password form to override the parent one. I have tried the following (in my child theme functions.php)

    function child_remove_wp_bootstrap_starter_password_form() {    
      remove_filter( 'wp_loaded', 'wp_bootstrap_starter_password_form');
    }
    add_action('init', 'child_remove_wp_bootstrap_starter_password_form');
    
    function new_password_form()   {
      global $post;    
      $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );    
      $o = '<form action="' . esc_url( home_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">    <div class="d-block mb-3">' . __( "My new text in french", "wp-bootstrap-starter" ) . '</div>    <div class="form-group form-inline"><label for="' . $label . '" class="mr-2">' . __( "Some more french", "wp-bootstrap-starter" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" class="form-control mr-2" /> <input type="submit" name="Submit" value="' . esc_attr__( "French Button", "wp-bootstrap-starter" ) . '" class="btn btn-primary"/></div>    </form>';    
      return $o;
    }
    add_filter('the_password_form', 'new_password_form');

    My guess is I am missing something regarding when the function must be called, and it always comes before the function of the parent theme, thus being overriden by the original one.

    Am I doing something wrong? Is there a better way to do this?

    On a side note I would also like to add an hyperlink in the french text, but I am not quite sure how to include the tags in the text.

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author Afterimage Designs

    (@afterimagedesigns)

    Hi @gotygota,

    Thanks for your comment about our theme. I see that you use this as a reference https://code.tutsplus.com/articles/customizing-and-styling-the-password-protected-form–wp-22375. The code add_filter must have a priority, you could try 11 or other numbers but in my case I use 11 https://prnt.sc/xsa897. Here’s my sample password page https://backend.ai.wpstaging.net/sample-page/.

    Regards,
    WP Bootstrap Starter

    Thread Starter gotygota

    (@gotygota)

    Fantastic that worked! Thank you very much!

    In case someone as the same issue, removing the parent function is not necessary. The final code snippet I used was the following:

    add_filter('the_password_form', 'new_password_form', 11);
    
    function new_password_form ()   {
        global $post;    
        $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );    
        $o = '<form action="' . esc_url( home_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">    <div class="d-block mb-3">' . __( "THE NEW TEXT", "wp-bootstrap-starter" ) . '</div>    <div class="form-group form-inline"><label for="' . $label . '" class="mr-2">' . __( "TEXT BEFORE PASSWORD BOX", "wp-bootstrap-starter" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" class="form-control mr-2" /> <input type="submit" name="Submit" value="' . esc_attr__( "BUTTON TEXT", "wp-bootstrap-starter" ) . '" class="btn btn-primary"/></div>    </form><p> SOME EXTRA TEXT UNDER THE FORM </a>.</p> ';    
        return $o;
    }

    Thanks again for the help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change password form text’ is closed to new replies.