• HI

    Im trying to make what seems like a simple adjustment to a plugin im using, unfortunately im just a ‘wannabe programmer’ and not the real deal so i wa shoping someone whom is a real programmer can help me out here. If you can help me i would be foreever grateful and even willing to pay a bit for someone to explain this process to me…… here goes:

    Im working with a plugin, it has a list of posts recently created and shows ALL posts no matter which user i login with… I would like to change this to show ONLY post by the user whom is logged in… Below si the current code

    <?php
    global $wpdb;
    $current_time = current_time(‘mysql’) + 60;

    $ereminder_array = $wpdb->get_results( $wpdb->prepare(“
    SELECT *
    FROM {$wpdb->posts}

    WHERE post_date <= %s

    AND post_type =’ereminder’
    AND post_status = ‘draft’
    AND author = ‘wp_current_user’
    ORDER BY post_date ASC
    “, $current_time) );
    $scheduled_data = array(
    ‘list’ => $ereminder_array,
    ‘type’ => ‘scheduled’
    );
    echo PDER_Utils::get_view( ‘ereminder-list.php’, $scheduled_data );
    ?>

    if anybody can tell me how to alter above code to show only post by the user that is logged in instead of all the users like it does now i would be forever grateful.

    thanks in advance

Viewing 1 replies (of 1 total)
  • Try this:

    global $wpdb;
    $current_time = current_time('mysql');
    $author_id = get_current_user_id();
    
    $ereminder_array = $wpdb->get_results( $wpdb->prepare("
    SELECT *
    FROM {$wpdb->posts}
    
    WHERE post_date <= %s
    
    AND post_type ='ereminder'
    AND post_status = 'publish'
    AND post_author = %d
    ORDER BY post_date ASC
    ", $current_time, $author_id ) );

Viewing 1 replies (of 1 total)
  • The topic ‘display post for logged in user only’ is closed to new replies.