• Hi all,

    My apologies if this is in the wrong place, or has already been covered. I did a quick search and couldn’t find anything that matched my query.

    I am looking to modify the default text of our site’s “Password Protection page”, and I know it’s possible thanks to this FAQ, but my query is a little more specific. I would like to place a Form I have specially created into the page, to act as a kind of form-gate for us. Essentially a visitor will be required to fill in the form, and I can then forward them the password to progress further into the site.

    For starters, is this even possible? And secondly, assuming it is possible, does anybody know if the confirmation will show properly, or will it freak out slightly due to the nature of the Password Protection page.

    Many thanks for your responses in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    You can use the ‘the_password_form’ filter to return any sort of form HTML you want. If you will eventually still let WP verify the password and grant access, the password field when posting to wp-login.php?action=postpass must be named ‘post-password’.

    Before that happens, you could have your initial form post to whatever code page you want that can handle forwarding the password or whatever other actions you want to take. If this code page is to use WP functions, your options of what the form submits to are limited. You can use AJAX, post to a WP page based on a custom template, or post through /wp-admin/admin-post.php. You cannot post to your own PHP code page if you want to use WP functions.

    As long as you conform to these guidelines, there will not be any freaking out on WP’s behalf ??

    Thread Starter jonrolph

    (@jonrolph)

    bcworkz,

    Thank you for your response. Just to clarify, those instructions will allow me to replace the Excerpt with a custom made Gravity Form (I realise that I didn’t clarify what type of Form it was) successfully?

    Moderator bcworkz

    (@bcworkz)

    I’m not familiar with gravity forms, but yes, I believe the filter hook can return a gravity form. I assume the forms normally appear through the use of a shortcode? Then your filter callback can get the form with something like $form = do_shortcode('[gravity_form id=3]'); My shortcode syntax is merely a guess, but the overall concept is valid.

    I’m guessing gravity forms send form submits as emails, or can the submits go to a code page, or either or? If it delivers emails where you collect the information, then send the user the password, you would need to actually send a link with a specific URL parameter so your filter callback can decide whether it should return the initial gravity form or return the default password field.

    It may be possible to have a two part gravity form with both a password field and the initial data fields. If the user has a password, they only need to fill in the one field. Some JavaScript will be necessary to change what happens to the form submit should the user use the password field, you do not want that sent as an email!

    If you’re going to be sending links instead of just passwords, it’d be even nicer to have the link simply deliver the content without having to enter a password. For this to work, I think you need a custom variation of the_content() that checks for a security token instead of a password. I don’t see anyway for the usual post_password_required() to work off an URL parameter, it’s cookie based only.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Placing a Form in the Password protect page’ is closed to new replies.