From 21dcfb25d98a3dc572534796049f9ca76bcfdecb Mon Sep 17 00:00:00 2001 From: michelvaldrighi Date: Wed, 25 Aug 2004 15:12:10 +0000 Subject: [PATCH] added user_can_edit_post and user_can_delete_post git-svn-id: http://svn.automattic.com/wordpress/trunk@1561 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions-post.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index 4f70f5119..fced51f45 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -354,4 +354,29 @@ function trackback_url_list($tb_list, $post_id) { } } + +// query user capabilities + +/* returns true if a given $user_id can edit a given $post_id. + note: optional $blog_id for future usage? */ +function user_can_edit_post($user_id, $post_id, $blog_id = 1) { + $author_data = get_userdata($user_id); + $post_data = get_postdata($post_id); + $post_author_data = get_userdata($post_data['Author_ID']); + + if ( ($user_id == $post_author_data->ID) + || ($author_data->user_level > $post_author_data->user_level) ) { + return true; + } else { + return false; + } +} + +/* returns true if a given $user_id can delete a given $post_id. + note: optional $blog_id for future usage? */ +function user_can_delete_post($user_id, $post_id, $blog_id = 1) { + // right now if one can edit, one can delete + return user_can_edit_post($user_id, $post_id, $blog_id); +} + ?> \ No newline at end of file