comment puis-je vérifier si le poste actuel appartient à l'auteur actuel? c'est mon code de base; `
if($curpost) {
wpuf_edit_show_form($curpost);
} else {
$error = "there is no post.";
}
`
aussi, comment puis-je ajouter le même contrôle à ces actions? `
function wpuf_user_dashboard_post_list() {
global $wpdb, $userdata;
get_currentuserinfo(); // grabs the user info and puts into vars
//delete post
if ($_REQUEST['action'] == "del")
{
check_admin_referer('wpuf_del');
wp_delete_post($_REQUEST['pid']);
echo '<div class="success">deleted.</div>';
}
//get the posts
$sql = "SELECT ID, post_title, post_name, post_status, post_date "
. "FROM $wpdb->posts "
. "WHERE post_author = $userdata->ID AND post_type = 'post' "
. "AND (post_status = 'publish' OR post_status = 'pending' OR post_status = 'draft') ";
$posts = $wpdb->get_results($sql);
$count = 1;
//d($posts);
`
merci.
Une version compactée qui ne charge pas encore les globals les appelle directement.
if(
is_user_logged_in() and // Force user validation... STUFF
!empty($GLOBALS['post']) and // Check if a $post exists in globals
!empty($GLOBALS['current_user']) and // Check if current_user exists in globals
($GLOBALS['current_user']->ID == $GLOBALS['post']->post_author) // Match User IDs
){
// This is your Author speaking, use the Force!
}
Cordialement.