简体   繁体   中英

Want to password protect a Wordpress page and have a PHP function validate the password

This is so I can apply a regular expression to the supplied password and give a yes/no with a simple regular expression.

Before everyone jumps on me to say this is terribly insecure, I know. It is intended to be used to to protect family photos. My family knows the name of my cat, so I'll accept a variety of passwords, based on that, with a simple regular expression.

I've searched a bunch, but no idea how to do this.

Thanks.

Number of ways, write a dedicated page template - See https://developer.wordpress.org/themes/basics/template-hierarchy/ and https://codex.wordpress.org/Stepping_Into_Templates

OR

write privacy shortcode that brackets content https://codex.wordpress.org/shortcode#Escaping_Shortcodes

For all: serve up form html if no password passed, else if password and correct then serve page content.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM