0

I've trying to find out how to do this in wordpress and I've searched the web, but I can't find any easy way to make my visitor only see one link if they enter a password to be able to see it.

Is there any plugin or solution that could do that ?

3
  • I am not sure I understand the question. Something like this: wordpress.stackexchange.com/a/72993/21376 ?
    – s_ha_dum
    Commented Oct 11, 2013 at 22:09
  • Yeah I need something similar, but I want to put the password only to a specific link in the text of my wordpress article. Such as something with a input field neaby, and by entering the password, the link is made available
    – Xaltar
    Commented Oct 11, 2013 at 22:12
  • Sorry, still not clear what you want.
    – s_ha_dum
    Commented Oct 12, 2013 at 13:18

1 Answer 1

1

I think this is almost what the article Add Private Content to Posts via Shortcode talks about. But it's only for registered users:

add_shortcode('private', 'private_content');
function private_content($atts, $content = null) {
    if ( is_user_logged_in() )
        return '<div class="private-content">' . $content . '</div>';
    return '';
}

And used inside the post/page like:

[private]
This post contains registered-only content!
[/private]

To add a password functionality, you'd have to add a <form> inside the shortcode function and show the content after the password is successfully $_POSTed.
Maybe it's more straight forward using Ajax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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