正在尝试从here 到我的用例:
function wpbeginner_restrict_editing( $allcaps, $cap, $args ) {
// Bail out if we\'re not asking to edit or delete a post ...
if( \'edit_post\' != $args[0] && \'delete_post\' != $args[0]
// ... or user is admin
|| !empty( $allcaps[\'manage_options\'] )
// ... or user already cannot edit the post
|| empty( $allcaps[\'edit_posts\'] ) )
return $allcaps;
// Load the post data:
$post = get_post( $args[2] );
// Bail out if the post isn\'t published:
if( \'publish\' != $post->post_status )
return $allcaps;
//if post is older than 30 days. Change it to meet your needs
if( strtotime( $post->post_date ) < strtotime( \'-30 day\' ) ) {
//Then disallow editing.
$allcaps[$cap[0]] = FALSE;
}
return $allcaps;
}
add_filter( \'user_has_cap\', \'wpbeginner_restrict_editing\', 10, 3 );
这很有效,但是我如何使用秒或分钟,而不是天?比如说,“300秒”似乎不起作用。