I've got a WP page containing a survey. The survey will be accessed by different people everyday (for simplicity say everyday for the whole year). I would like to password protect it and the password suppose to be changed everyday at midnight-ish. However to some extent the password should be formatted to be predictable for managers sharing the link to the survey (they can easily work-out what's today's password)- but not predictable to the end users :)
So for instance the password on the 2nd of Oct could look like
var day = currentDay
var month = currentMonth
var pass = "D!" + month + "K#" + day //formula passed to the managers
resulting in that day's password: D!10k#2
This solution doesn't have to be supa strong, it's just to protect the survey from overuse by "not expected" people. I've read this topic but it does not seem relevant that much.
Many thanks for reading and for any help :) Enjoy your Friday!
Rafał
//EDIT It seems I would have to create a real CRON job triggering wp_cron and actually the code from the post I mentioned before would have to be modified to generate password according to the formula above. I know very little about php, so any help would be appreciated. No explanation regarding implementation is required though :)
//EDIT 2 Actually I find the post very useful, it just needs some tweaking, but I'm far from calling myself php delveloper so wanted ask for help.
I removed all scheduling code and left with a tiny bit of php code. Would the below snippet be enough to work if triggered by real CRON job? And what would be the formula to use marked below: FORMULA?
<?php
add_action( 'wpse_change_pass_event', function()
{
$slug = 'hello-world'; // Edit this post slug to your needs!
$formula = WHAT HERE? :)
global $wpdb;
$wpdb->update(
$wpdb->posts,
array( 'post_password' => $formula ),
array( 'post_name' => $slug ),
array( '%s' ),
array( '%s' )
);
});