0

I am developing a viewing room for an art gallery. Viewing rooms are pages with content that can only be seen by visitors if they provide their email address to add them to a newsletter. Something like the following site: https://www.davidzwirner.com/viewing-room/james-welling.

I know that pages and posts in WordPress can be password protected, but I don't need this type of protection. Is there any action I can hook to do this? Basically, I need to show a form so visitors can type their email address. Once they do this, they are added to a newsletter (a Mailchimp one, for example), and then the actual page is shown. Also, a cookie must be set so they don't have to provide their email address again to access this page in the future.

Thanks in advance

1

What about filtering the_content?

function se365701_require_email ( $content ) {
    if ( is_page( 'require_email' ) ) && !isset( htmlspecialchars( $_COOKIE['submitted_email']) ) {
      return $form; // your MailChimp Form Code
    } else{
        return $content;
}
add_filter( 'the_content', 'se365701_require_email' );

Note that your form provide itself may have a cookie or you may need to set it when the form is filled out. You could also perhaps use $_POST[] or $_GET instead. You just need some way of knowing if the form was submitted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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