I have a site where young artists may show their work.
Young = under 29 years
Artist = custom post
Work = child custom post of artist
The artist gives his/her birth date in the artist profile and in the site the age is shown in single view of artist. Here I use this snippet (found it somewhere):
add_shortcode( 'time_ago', 'time_ago_func');
function time_ago_func($atts){
global $wpdb;
extract( shortcode_atts( array(
'birthdate' => '',
), $atts ) );
//explode the date to get month, day and year
//$birthDate = explode("-", $birthDate);
//get age from date or birthdate
//$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md") ? ((date("y")-$birthDate[2])-1):(date("Y")-$birthDate[2]));
$age = floor((time() - $birthdate)/(365*24*60*60));
return $age;
}
and into content template this shortcode
[time_ago birthdate='[types field="syntymapaiva" raw="true" id=""][/types]']
Now my 2 big challenges as a non-PHP-coder are these:
1. the artist profile and her/his works should be hidden when the artist is 29 years
2. the artists should get notification one month before his/her artist profile will be hidden.
Any hints and recommendations how to achieve this are very very welcome.
Unfortunately I cannot help with this one much because it would require some amount of extensive custom code to achieve, especially to send the mail to the user when his/her age is 29.
Hiding the profile would require a cron job to run a function that would check all the posts atleast once a day. Have a look at the link below to see a simple tutorial on how to setup a cron job. hidden link
If you're unsure of how to setup this you may consult with a contractor by contacting them from the link below. https://toolset.com/contractors/
However the best plan of action is by setting up a cron job to run your function that would disable the posts as well as send the mail to the user.