Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Anyone know what I am doing wrong here? I have this code in a functions.php file in a Wordpress Child Theme.

<?php
function my_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
' . __( "This content is CLASSIFIED, for subscribers only! To get access, <a href="http://maryefern.com/join">join here</a>, check your e-mail for a message from me with the password, and enter it below:" ) . '
<label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
</form>
';
return $o;
}
add_filter( 'the_password_form', 'my_password_form' );
?>
share|improve this question

closed as off-topic by Fred -ii-, Clive, Ondkloss, andrewsi, Piyush Feb 10 at 3:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Fred -ii-, Clive, Ondkloss, andrewsi, Piyush
If this question can be reworded to fit the rules in the help center, please edit the question.

4  
Look at the syntax highlighting and you'll see. –  ceejayoz Feb 9 at 21:03

1 Answer 1

up vote 0 down vote accepted

That error generally means you have some text (string) where there shouldn't be. When I get this error it means I probably haven't escaped something correctly or haven't "jumped" in/out of php correctly.

To help minimize this, I'll separate my markup/output into different lines. Sure it makes the code longer (more lines) but it just helps keep things straight.

I don't know if this code works or not, but at least your error is gone. @ceejayoz is right, syntax highlighting should help you here.

php

    function my_password_form() {
        global $post;
        $label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );

        $o = '<form action="' . esc_url(site_url('wp-login.php?action=postpass', 'login_post')) . '" method="post">';
        $o .= '(This content is CLASSIFIED, for subscribers only! To get access, <a href="http://maryefern.com/join">join here</a>, check your e-mail for a message from me with the password, and enter it below:)';
        $o .= '<label for="' . $label . '">' . ( "Password:" ) . '</label>';
        $o .= '<input name = "post_password" id = "' . $label . '" type = "password" size = "20" maxlength = "20" /><input type = "submit" name = "Submit" value = "' . esc_attr__( "Submit" ) . '" />';
        $o .= '</form>';

        return $o;
}

add_filter('the_password_form', 'my_password_form');
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.