WordPress.org

Forums

Query Posts by Registration Date (1 post)

  1. jason_donnini
    Member
    Posted 2 years ago #

    I have implemented S2 member plugin and and querying posts by registration date and forward. However, I am not getting this result with the query I currently have. The first part is converting the unix time to human second part is querying the specific date forward. Would like to have the prior 30 days as well.

    <?php function unix_timestamp_to_human ($timestamp = "", $format = 'Y-m-d')
    {
        if (empty($timestamp) || ! is_numeric($timestamp)) $timestamp = time();
        return ($timestamp) ? date($format, $timestamp) : date($format, $timestamp);
    }
    
    $unix_time = S2MEMBER_CURRENT_USER_REGISTRATION_TIME;
    
      function filter_where($where = '') {
        $where .= " AND post_date > '" . date('unix_timestamp_to_human($unix_time)', strtotime('-30 days')) . "'";
        return $where;
      }
    add_filter('posts_where', 'filter_where');
    query_posts($query_string); ?>

    Please Advise...

Topic Closed

This topic has been closed to new replies.

About this Topic