Php/Javascript Challenge!

7 replies
I have a wordpress blog where I am trying to customize the "This post is password protected. To view it please enter your password below:" I want to simply create a link
<a href="http://www.website.com">Join Today</a> that non-members can click on to become a member. I've tried adding this but I get a string error...

I have been banging my head on how to create this link within this function. I would appreciate any input you may have! See the code below...

Specifically this is the line that I need to modify:

<p>' . __("Not a member? Goto http://www.website.com"). '</p>


function get_the_password_form() {
global $post;
$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
$output = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post">
<p>' . __("This post is password protected. To view it please enter your password below:") . '</p>
<p>' . __("Not a member? Goto http://www.website.com"). '</p>
<p><label for="' . $label . '">' . __("Password:") . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr__("Submit") . '" /></p>
</form>
';
return apply_filters('the_password_form', $output);
}
#challenge #php or javascript
  • Profile picture of the author GB2008
    This works on my test server here, though I had to remove references to your functions get_option(), esc_attr(), apply_filters() as I don't have that code...

    <?php
    echo get_the_password_form();
    ?>

    <?php

    function get_the_password_form() {
    global ;
    = 'pwbox-'.(empty() ? rand() : );
    = '<form action="/wp-pass.php" method="post">
    <p>' . ("This post is password protected. To view it please enter your password below:") . '</p>
    <p>' . ("Not a member? Goto <a href="http:///www.website.com">http://www.website.com</a>"). '</p>
    <p><label for="' . . '">' . ("Password:") . ' <input name="post_password" id="' . . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="Submit" /></p>
    </form>
    ';
    return ;
    }
    ?>
    Signature
    {{ DiscussionBoard.errors[946438].message }}
    • Profile picture of the author Active_One_2006
      Hi Gary,

      Thanks for looking into this. I'm not sure the syntax is correct here

      <p>' . ("Not a member? Goto <a href="http:///www.website.com">http://www.website.com</a>"). '</p>

      For some reason it will not create the hyperlink and then throws a syntax error...
      {{ DiscussionBoard.errors[946831].message }}
      • Profile picture of the author Steve Diamond
        You just have to escape the inner set of quotes by preceding each with a backslash. I tried to demonstrate in this post, but the forum won't display the backslashes even when I wrap the line in code tags. What I mean is, insert a backslash right before the quote that precedes http and another backslash right before the quote that follows .com.

        Steve
        Signature
        Mindfulness training & coaching online
        Reduce stress | Stay focused | Keep positive and balanced
        {{ DiscussionBoard.errors[947041].message }}
        • Profile picture of the author Active_One_2006
          Thank you Steve, bang on! It worked beautifully!
          {{ DiscussionBoard.errors[947220].message }}
  • Profile picture of the author GB2008
    Thanks Steve - I didn't notice those had gone missing in my post!
    Signature
    {{ DiscussionBoard.errors[947304].message }}
  • Profile picture of the author solidsoul
    No job, just off a quick glance post you nailed the issue! php coders to the rescue
    {{ DiscussionBoard.errors[954286].message }}

Trending Topics