BuddyDev

Search

[Resolved] Restrict access to galleries based on Paid Memberships Pro membership levels

  • Participant
    Level: Initiated
    Posts: 1
    Damian Caynes on #19563

    Hi,

    I notice you have a plugin to restrict upload levels to galleries for Paid Memberships Pro, but I would like to restrict access to actually viewing galleries for non paid users.

    Does anyone have an idea/code snippet to do this? I’m sure it’s been done before.

    Thanks,

    Damian

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #19565

    Hi Damian,
    Thank you for using MediaPress.

    You can use something like this

    
    
    function mpp_custom_gallery_view_restriction() {
    
    	if ( is_super_admin() || bp_is_my_profile() || ! mpp_is_single_gallery() || ! function_exists( 'pmpro_getMembershipLevelForUser' ) ) {
    		return;
    	}
    
    	$level = pmpro_getMembershipLevelForUser( get_current_user_id() );
    
    	// do your check here and
    
    	if ( ! $level ) {
    		// restrict.
    		bp_core_redirect( home_url( '/' ) );
    	}
    
    }
    
    add_action( 'bp_template_redirect', 'mpp_custom_gallery_view_restriction' );
    

    Please modify it according to your need.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 1
    Damian Caynes on #19593

    Thanks so much!

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #19599

    You are welcome.

The topic ‘ [Resolved] Restrict access to galleries based on Paid Memberships Pro membership levels’ is closed to new replies.

This topic is: resolved