This topic has 2 replies, 2 voices, and was last updated 7 years by Carlene.

  • Author
  • #181856
     Carlene
    Participant

    Hi, I am offering many levels to my membership. I have a membership software that lets me limit access to places, but on my directory everyone shows up. I do not want my Free members listed in the directory. Is there a way to do that. The actual wp user role is called Free.

    I also would like to remove friendship and all subscriptions when someone reverts to Free from another membership level, is there a way to do that?

    Thanks

    Carlene

    #181858
     Kieran_SQ
    Moderator

    Hi,

    Thanks for contacting us about memberships. You can use the below snippet to hide users with the role ‘free’ in the BuddyPress member’s directory. You will need to use a bp-custom.php in your plugins folder to guarantee this to work properly all of the time.

    COPY CODE
    add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);
    function bpdev_exclude_users($qs=false,$object=false){
        //list of users to exclude
         
        if($object!='members')//hide for members only
            return $qs;
        
         $excluded_user=join(',',bpdev_get_subscriber_user_ids());//comma separated ids of users whom you want to exclude
            
        $args=wp_parse_args($qs);
        
        //check if we are searching for friends list etc?, do not exclude in this case
        if(!empty($args['user_id']))
            return $qs;
        
        if(!empty($args['exclude']))
            $args['exclude']=$args['exclude'].','.$excluded_user;
        else 
            $args['exclude']=$excluded_user;
          
        $qs=build_query($args);
       
       
       return $qs;
        
    }
    
    function bpdev_get_subscriber_user_ids(){
      
        $subscribers= get_users( array( 'role' => 'free', 'fields' => 'ID' ) );
      
       return $subscribers;
    }

    If you do not already have a bp-custom.php file setup you can download the one I have attached for you that already contains the code from above. You should upload this file via ftp directly into the /wp-content/plugins/ folder.

    “I also would like to remove friendship and all subscriptions when someone reverts to Free from another membership level”. This would be a function suited to your third party memberships plugin and you should contact their development team to implement this for you.

    Thanks,

    Kieran.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    Attachments:
    You must be logged in to view attached files.
    #182834
     Carlene
    Participant

    Thank you. That worked.

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?