Support » Plugin: p5 : Plenty of Perishable Passwords for Protected Posts » Plugin not working when I modify the Password page

  • Resolved mvmedia

    (@mvmedia)


    Hi Cyril,
    Thanks again for your great work.
    I am trying to modify the password form by adding the following function to my functions.php

    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"><h3>
        ' . __( "If you do not have a password, please fill in form below</br> or call <b>781-772-2539</b> for assistance." ) . '</h3>
    
        <label class="pass-label" for="' . $label . '">' . __( "PASSWORD:" ) . ' </label>
    	<input name="post_password" id="' . $label . '" type="password" style="background: #ffffff; border:1px solid #999; color:#333333; padding:10px; " size="14" /><input type="submit" name="Submit" class="button" style="margin-left: 10px;" value="' . esc_attr__( "Submit" ) . '" />
        </form>
        ';
        return $o;
    }

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    when I add this none of the passwords work. Any ideas?
    Thanks so much.
    by the way, I tried to make a donation but there is no donate button.
    Mary-Ellen

    https://wordpress.org/plugins/p5/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Cyril Batillat

    (@cyrilbatillat)

    Hi Mary-Ellen,

    The P5 plugin itself already use the_password_form filter to add an hidden input. (see function modify_password_form() in index.php on ligne 616).

    At first, I suggest you to modify the filter hook like this :
    add_filter( 'the_password_form', 'custom_password_form', 11 );
    the priority ’11’ ensure that your code will be performed after P5’s code (default priority is set to 10, which is used by P5 plugin).

    What you are trying to modify with your code ? It seems that it’s the one given in WordPress Codex. Is this just about changing some labels ?
    You can find some exemples here : http://diythemes.com/thesis/rtfm/password-protected-form/

    P5 plugin use DOMDocument technique to add code at a specific place, without altering original form.

    I didn’t expect to have some donation requests. I you wish to make a donation, here is my Paypal account : cyril.batillat [at] gmail [dot] com

    Regards,

    HI Cyril,
    Thanks for your quick responses.
    I am trying to just change the default text. I changed the code with adding the default priority and it still does not work.
    I also tried the changes from the diy form and they did not work either. I think I will have to add your code to the functions.php for the theme, but I am not sure how to get my changes in there with the DOMDocument technique.
    Any other suggestion?
    Thanks again.
    Mary-Ellen

    Plugin Author Cyril Batillat

    (@cyrilbatillat)

    Hi Mary-Ellen,

    This exemple did’nt work ?

    An other way is to use gettext hook to alter translatable strings.

    Exemple :

    add_filter( 'gettext', 'change_password_form_prompt', 20, 3 );
    
    function change_password_form_prompt( $translated_text, $text, $domain ) {
         if( $translated_text !== 'This content is password protected. To view it please enter your password below:' ) return $translated_text;
        return '[Your custom string here]';
    }

    I can give you some more help if you send me some more infos (URL, FTP access,…) You can contact contact me privately at contact [at]bazalt[dot] fr

    Regards,

    Hi Cyril,
    Where or how do I contact you with the above credentials? Skype?
    Thanks,
    Mary-Ellen

    Plugin Author Cyril Batillat

    (@cyrilbatillat)

    No Mary-Hellen, this is my mail. Simply remove the whitespaces, and replace [at] by “@” and [dot] by “.” (without quotes)
    This is a simple protection against robots.

    HI Cyril,
    I got the code above to work! Thanks so much. I appreciate your time.
    Mary-Ellen

    Plugin Author Cyril Batillat

    (@cyrilbatillat)

    Great !

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Plugin not working when I modify the Password page’ is closed to new replies.