Membership 2 not protecting URL

Have a URL: https://mela*******.com/business-directory/?wpbdp_view=submit_listing

This should not be accessible to default user, but it's not blocking once they are logged in, the URL restriction is not protecting it

  • Ash

    Hello New Guy

    I can confirm the issue on my test site. So I am marking this as a bug and reporting to the developer. Hopefully, very soon the issue will be fixed and an update will be released. We appreciate your patience on this.

    For a workaround, please try the following code:

    add_filter( 'ms_rule_url_model_check_url_expression_match', function( $match, $url, $check_list ){
    
    	$match 		= false;
    	$check_list = mslib3()->array->get( $check_list );
    
    	if ( count( $check_list ) ) {
    		$check_list = array_map( 'strtolower', $check_list );
    		$check_list = array_map( 'trim', $check_list );
    
    		$url 	= strtolower( $url );
    		$parts 	= parse_url( $url );
    
    		//Remove https port from the url
    		if( ( isset( $parts['port'] ) && isset( $parts['scheme'] ) ) && ( $parts['scheme'] == 'https' && $parts['port'] = '443' ) ) {
    			unset( $parts['port'] ); //remove port
    			$url = MS_Helper_Utility::build_url( $parts );
    		}
    
    		foreach ( $check_list as $check ) {
    			if (false === empty($check) && trim($check) == $url ) {
    				$match = true;
    				break;
    			}
    		}
    	}
    
    	return $match;
    
    }, 99, 3);

    You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Have a nice day!

    Cheers,
    Ash

  • Vaughan

    Hi New Guy

    Further to what Ash said above, you can also simply hide the button itself with CSS so only members belonging to your business plan can see the button.

    This CSS should do the trick:

    input#wpbdp-bar-submit-listing-button {
        display: none;
    }
    body.ms-801 input#wpbdp-bar-submit-listing-button {
    display: inline-block !important;
    }

    Where 801 is the membership id of your business plan.

    Cheers

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.