I got above working now. But it doesn't solve my problem. My problem is that i don't want to manualy edit someones birthday by save.
Is it posible to make a php file or a view that updates every birthday age of every person in of the post type 'person'. So that i can execute this view or file everyday of it does it after login?
This is what i have so far (in functions.php) and it works when i save a post. But i realy would like to automate this by a script or something… Can you please help?
/**
*Function birthday 11-08-1972
*/
function birthday ($birthday){
list($day,$month,$year) = explode("-",$birthday);
$year_diff = date("Y") – $year;
$month_diff = date("m") – $month;
$day_diff = date("d") – $day;
if ($day_diff < 0 || $month_diff < 0)
$year_diff–;
return $year_diff;
}
/**
*Function update age on save
*/
function my_project_updated( $post_id ) {
$persoon_geboren = get_post_meta($post_id, 'wpcf-geboortedatum', true);
update_post_meta($post_id, 'wpcf-leeftijd', birthday( $persoon_geboren) );
}
add_action( 'save_post', 'my_project_updated', 100 );