Vyřešeno:
function stoppostedition_filter( $capauser, $capask, $param){
global $wpdb;
$post = get_post( $param[2] );
if( $post->post_status == 'publish' ){
if( $capauser == 1 ){
if( ( $param[0] == "edit_post") || ( $param[0] == "delete_post" ) ) {
$post_time_unix = strtotime( str_replace(‘-‘, ‘:’, $post->post_date ) );
$current_time_unix = time();
$diff = $current_time_unix – $post_time_unix;
$hours_after_publication = floor( $diff / 60 / 60 );
if( $hours_after_publication >= 168 ){
foreach( (array) $capask as $capasuppr) {
if ( array_key_exists($capasuppr, $capauser) ) {
$capauser[$capasuppr] = 0;
}
}
}
}
}
}
return $capauser;
}
add_filter(‘user_has_cap’, ‘stoppostedition_filter’, 100, 3 );