Change password form text
-
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!
- The topic ‘Change password form text’ is closed to new replies.