help with membership pro payments

Hello,

I am trying to use membership pro with buddypress and I have a couple of things that I cant work out.
Firstly how do I get a payment button into the sign up form? I can fill the whole thing out on a test without being asked to pay anything. http://www.mdnbeta.org/register-2/
Secondly I want to be able to stop some forms of membership from being shown in the members list as only certain members get their details listed- http://www.mdnbeta.org/members/

Could you help at all? I am sure I am missing the obvious but have been through everything and cant work it out.

Thanks

  • Vaughan

    Hi @whosjack,

    Hope you're well?

    Are you using the buddypress registration page or membership?

    You can't have both enabled, Disable the buddypress registration page in

    Dashboard > settings > buddypress > pages

    Select none for registration page.

    Then select the registration page instead in membership

    Dashboard > membership > options > membership pages

    Membership will still use the buddypress custom profile fields that are in the base group.

    That should sort the registration out.

    With regards to excluding specific memberships, that is a bit trickier, it's easier if you just want to exclude admins or a specific user role, if that's what you need?

    Or if it's a specific membership level you want removing, I suppose we could modify the following script.

    https://gist.github.com/dzmounir/6043674

    Try this, hopefully it should work, though I haven't tested.

    Create a file called wpmu_functions.php

    Then once done, upload this file to /wp-content/mu-plugins/

    If mu-plugins folder doesn't exist, create it.

    In this file add the following code. (make sure <?php is on the very first line in the file)

    <?php
    add_action( 'bp_legacy_theme_ajax_querystring','bprm_exclude_members',20 , 2 );
    add_action( 'bp_ajax_querystring','bprm_exclude_members',20 , 2 );
    
    function bprm_exclude_members( $qs=false, $object = false ){
    
      global $bp;
    
    	//list of users to exclude
    	//comma separated ids of users whom you want to exclude
    	// for example '0,1,54'
    	$excluded_members = join( ',', wpmudev_get_members_user_ids() );
    
    	//if the current loggedin member is in the excluded members
    	//then the exclusion is ignored
    	if ( bp_loggedin_user_domain() ) {
    		$user_id = $bp->loggedin_user->id;
    		if ( in_array( $user_id , explode( ",", $excluded_members ) ) )
    			return $qs;
    	}
    
    	if( $object != 'members' )//hide for members only
    		return $qs;
    
    	$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_members;
    	else
    		$args['exclude'] = $excluded_members;
    		$qs = build_query($args);
    	return $qs;
    }
    
    add_filter( 'bp_core_get_user_domain', 'bprm_core_get_user_domain' ,10 , 4 );
    function bprm_core_get_user_domain($domain, $user_id, $user_nicename, $user_login){
    
    	global $bp;
    
    	//list of users to exclude
    	// for example array(1,2,55)
    	$excluded_members = wpmudev_get_members_user_ids();
    
    	//if the current loggedin member is in the excluded members
    	//then the exclusion is ignored
    	if ( is_user_logged_in() ) {
    		$loggedin_user_id = $bp->loggedin_user->id;
    		if ( in_array( $loggedin_user_id , $excluded_members ) )
    			return $domain;
    	}
    
    	if ( in_array( $user_id , $excluded_members ) )
    		return null;
    }
    
    function wpmudev_get_members_user_ids(){
        global $wpdb;
    
        $mem_pro_sub_levels = array(1);
    
        foreach($mem_pro_sub_levels as $mems) {
            $query = "SELECT user_id FROM {$wpdb->prefix}m_membership_relationships WHERE sub_id = $mems";
            $user_ids = $wpdb->get_results($query, ARRAY_A);
        }
    
        foreach($user_ids as $key) {
            foreach($key as $k => $val) {
                $admins[] = $val;
            }
        }
    	return $admins;
    }

    To select a subscription plan, just add the subscription ID to the following line;

    $mem_pro_sub_levels = array(1);

    So in this case 1 = subscription level id 1

    Hope this helps

  • Ash

    Hello @whosjack

    I hope you are well :slight_smile:

    This seems to work except when you change the order all the code shows and you have to refresh the screen before it works again.
    It also all shows at the top of the users edit back end screen and at the top of every page.

    Would you please post a screenshot of "all the code shows"?

    And just to be more sure, you want to exclude members having a certain membership from the BP members page, right?

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.