Jump to content

wrong syntax in line of code


Mr.Canuck

Recommended Posts

Here is the full code snippet:

<?php 

function my_password_form() {
    global $post;
    $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    $o = '<form style="margin-left:265px" class="protected-post-form" action="http://example.com" '/wp-login?action=postpass' method="post">
    ' . __( "To enter AIS Cloud, please enter the username which was provided to you:" ) . '
    <label for="' . $label . '">' . __( "Username:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Login" ) . '" />
    </form>
    ';
    return $o;
}
add_filter( 'the_password_form', 'my_password_form' );

?>
Link to comment
Share on other sites

I don't know. Honestly, I'm just trying to learn.

 

Should I remove those single quotes like this?

<?php 

function my_password_form() {
    global $post;
    $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    $o = '<form style="margin-left:265px" class="protected-post-form" action="http://example.com" /wp-login?action=postpass method="post">
    ' . __( "To enter AIS Cloud, please enter the username which was provided to you:" ) . '
    <label for="' . $label . '">' . __( "Username:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Login" ) . '" />
    </form>
    ';
    return $o;
}
add_filter( 'the_password_form', 'my_password_form' );

?>
Link to comment
Share on other sites

Thank you for your help so far.

 

This part here has to be separated from the URL, as it controls the "check for password" function:

wp-login?action=postpass

If I do this

action="http://example.com/wp-login?action=postpass"

then when clicking the login button, it just takes me to the http://example.com site without verifying the password first.

 

Is there a way to get the /wp-login?action=postpass to work?

 

NOTE: If I do the code this way:

<?php 

function my_password_form() {
    global $post;
    $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    $o = '<form class="protected-post-form" action="' . get_option( 'siteurl' ) . '/wp-login.php?action=postpass" method="post">
    ' . __( "To enter our client area, please enter the password which was provided to you:" ) . '
    <label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
    </form>
    ';
    return $o;
}
add_filter( 'the_password_form', 'my_password_form' );

?>

it works. It actually checks for the verified password like it is supposed to, but the siteurl isn't correct, as I need it to go to a specific URL like http://example.com

 

Is there a way to use this line of code how it is, but make it not pull from . get_option( 'siteurl' ) but rather to go to http://example.com ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.