This topic has 1 reply, 2 voices, and was last updated 10 years by SQadmin.

  • Author
  • #7379
     vanaila
    Participant

    Hi,

    I want that registered but non-membership pro members be displayed in the member-list.

    Is that possible?

    Few times away I used this code

    COPY CODE
    
    /**
     * Get users with specified membership
     * @param array $membership
     * @return array
     */
    function get_membership_users($memberships)
    {
        global $wpdb;
        $sqlQuery = "SELECT u.ID FROM $wpdb->users u LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id LEFT JOIN $wpdb->pmpro_membership_levels m ON mu.membership_id = m.id";
        $sqlQuery .= " WHERE mu.membership_id > 0  AND mu.status = 'active' ";
        if($l)
            $sqlQuery .= " AND mu.membership_id IN (" . join(" , ",$memberships) . ") ";
        $sqlQuery .= "GROUP BY u.ID";
    
        $sqlQuery = apply_filters("pmpro_members_list_sql", $sqlQuery);
        $theusers = $wpdb->get_results($sqlQuery);
        
        $data = array();
        if ($theusers) {
            foreach ($theusers as $usr) {
                $data[] = $usr->ID;
            }
        }
        return $data;
    }
    
    //Change your membership levels ID - instead of level 1 and level 2
    global $my_paying_users;
    $my_paying_users = get_membership_users(array(1,2));
    
    //Hide recent user
    add_action('bp_init', 'kleo_private_members');
    function kleo_private_members(){
        global $bp, $my_paying_users;
        
        if ( ! in_array($bp->loggedin_user->id, $my_paying_users) )
        {
            remove_action("wp_head","bp_core_record_activity"); //id SM is on, remove the record activity hook
            //then remove the last activity, if present
            delete_user_meta($bp->loggedin_user->id, 'last_activity');
        }
    }
     
    //Hide member in Members directory page
    add_action('bp_ajax_querystring','kleo_exclude_users',20,2);
    function kleo_exclude_users($qs=false,$object=false)
    {
        global $my_paying_users;
        $included_user=implode(",",$my_paying_users);
     
        if($object!='members')//hide for members only
        return $qs;
        $args=wp_parse_args($qs);
        
        //check if we are listing friends?, do not exclude in this case
        if(!empty($args['user_id']))
        return $qs;
        
        if(!empty($args['include']))
        $args['include']=$args['include'].','.$included_user;
        else
        $args['include']=$included_user;
        $qs=build_query($args);
        return $qs;
    }
     
    /**
    * END Hide Admin
    */ 
     
    // Hide admin profile pages
    add_action( 'wp', 'hide_profile_template', 1 );
    function hide_profile_template() {
        global $bp, $my_paying_users;
        if(!bp_is_my_profile() && bp_is_member()) :
            if (! in_array($bp->displayed_user->id,$my_paying_users)):
                global $wp_query;
                $wp_query->set_404();
                status_header(404);
                include(locate_template('404.php'));
                exit;
            endif;
        endif;
    }
    

    It semed to me it was to hide non membership (but registered) members, but when I errase it they do not appeared again.

    Is there a way to make them appears?

    #7439
     SQadmin
    Keymaster

    that code would show just the members from those specific levels.
    Once they login they will appear on site

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?