function mgm_user_membership_info($user_id = NULL)
{
    // init
    $user = NULL;
    // get user
    if ($user_id) {
        $user = get_userdata($user_id);
    }
    // get current user
    if (!isset($user->ID)) {
        $user = wp_get_current_user();
    }
    // return
    if (!isset($user->ID)) {
        return "";
    }
    // token
    $token = mgm_get_rss_token();
    $url = home_url();
    $rss_url = add_query_arg(array('feed' => 'rss2', 'token' => $token), $url);
    $member = mgm_get_member($user->ID);
    // init
    $html = '';
    // token
    if (mgm_use_rss_token()) {
        $html .= '<div class="mgm_margin_bottom_10px">' . '<h4>' . __('RSS Tokens', 'mgm') . '</h4>' . '<div class="mgm_margin_bottom_10px">' . __('Your RSS Token is', 'mgm') . ': <strong>' . $token . '</strong></div>' . '<div class="mgm_margin_bottom_10px">' . __('Use the following link to access your RSS feed with access to private parts of the site.', 'mgm') . '<br /><br />' . '<a href="' . $rss_url . '">' . $rss_url . ' </a>' . '</div>' . '</div>';
    }
    // add unsubscribe button
    $html .= mgm_get_unsubscribe_status_button($member, $user);
    // apply filter
    return apply_filters('mgm_membership_details_html', $html, $user->ID);
}
/**
 * hide pages from list/menu, called by template tag wp_list_pages()
 * 
 * @param array $excluded
 * @return array $excluded
 */
function mgm_list_pages_excludes($excluded)
{
    global $wpdb, $user_ID;
    // if loading from feed
    if (is_feed() && isset($_GET['token']) && mgm_use_rss_token()) {
        // get user by rss token, only for feed
        $user = mgm_get_user_by_token(strip_tags($_GET['token']));
        $user_ID = $user->ID;
    } elseif (!$user_ID) {
        $current_user = wp_get_current_user();
        $user_ID = $current_user->ID;
    }
    // get system object
    $system_obj = mgm_get_class('system');
    // update
    $excluded_pages = $system_obj->get_setting('excluded_pages');
    // exclude
    if (is_array($excluded_pages) && is_array($excluded)) {
        $excluded = array_merge($excluded, $excluded_pages);
        // give preference to user settings
    }
    // hide post
    $hide_posts = mgm_content_exclude_by_user($user_ID, 'post');
    // check
    if ($hide_posts && is_array($excluded)) {
        $excluded = array_merge($excluded, $hide_posts);
        // give preference to mgm settings
    }
    // default pages, by session
    $hide_pages = mgm_exclude_default_pages();
    // check
    if ($hide_pages && is_array($excluded)) {
        $excluded = array_merge($excluded, $hide_pages);
        // give preference to mgm settings
    }
    // return array
    return $excluded;
}
function mgm_content_post_access_delay($args = array())
{
    global $user_data, $wpdb;
    // current user
    $current_user = wp_get_current_user();
    // get user by username
    if (isset($_GET['username']) && isset($_GET['password'])) {
        // ? who did this? and why
        $user = wp_authenticate(strip_tags($_GET['username']), strip_tags($_GET['password']));
    } else {
        if (is_feed() && isset($_GET['token']) && mgm_use_rss_token()) {
            // added feed check while updating iss#676
            // get user by rss token, only for feed
            $user = mgm_get_user_by_token(strip_tags($_GET['token']));
        } else {
            // else get current use if logged in
            $user = $current_user;
        }
    }
    //init
    $access_delay = array();
    //check
    if (isset($args['postdelay']) && !empty($args['postdelay'])) {
        $postdelay_membership_levels = explode(',', $args['postdelay']);
        foreach ($postdelay_membership_levels as $postdelay_membership_level) {
            if ($postdelay_membership_level) {
                $postdelay_membership_level = explode(':', $postdelay_membership_level);
                $access_delay[$postdelay_membership_level[0]] = $postdelay_membership_level[1];
            }
        }
    }
    //check
    if (!empty($access_delay) && !empty($user)) {
        // get member
        $member = mgm_get_member($user->ID);
        //check
        $allowed = mgm_check_post_access_delay($member, $user, $access_delay);
        if (!$allowed) {
            return true;
        }
    }
    // return
    return false;
}