Skip Navigation

[Resolved] Age condition

This support ticket is created 3 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by katjaL 3 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#1912029

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.

#1912311

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Katja,

Thank you for getting in touch.

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.

Please let me know if this helps.
Thanks,
Shane

#1912835

Ok, thank you I will contact a coder.