Domanda

Come posso verificare se il post corrente appartiene all'autore attuale? Questo è il mio codice di base; `

if($curpost) {
                wpuf_edit_show_form($curpost);
            } else {
                $error = "there is no post.";
            }

`

Inoltre come posso aggiungere lo stesso controllo a queste azioni; `

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);

`

Grazie.

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top