• Resolved teeboy4real

    (@teeboy4real)


    Hello,

    How can make this code to display to only the logged in author of the ad, Other users should not see this except the ad author

    /* ------------------------------------------------------------------------- *
     * WPadverts display ad expiration date
    /* ------------------------------------------------------------------------- */
    add_filter( "adverts_tpl_single_details", function($post_id) {
        ?>
        <div class="adverts-grid-row">
            <div class="adverts-grid-col adverts-col-30">
                <span class="adverts-round-icon adverts-icon-calendar"></span>
                <span class="adverts-row-title"><?php _e("Ad Expires", "wpadverts") ?></span>
            </div>
            <div class="adverts-grid-col adverts-col-65">
                <?php $exp_time = get_post_meta( $post_id, "_expiration_date", true ); ?>
                <?php if( $exp_time ): ?>
                <?php echo date_i18n( get_option( "date_format" ), $exp_time ) ?>
                <?php else: ?>
                Never
                <?php endif; ?>
            </div>
        </div>
        <?php
    } );

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    To show this to the Ad author only before ?> add

    
    $uid = get_current_user_id();
    if( $uid < 1 || $uid != get_post( $post_id )->post_author ) {
      return;
    }
    
Viewing 1 replies (of 1 total)
  • The topic ‘Display ad expiration date to only logged in author’ is closed to new replies.