BuddyDev

Search

Accept activity wall to be read only

  • Participant
    Level: Initiated
    Posts: 11
    johan on #28255

    Can u help to customize activity wall to be read only for free members?

    I use whether tagging or paid membership pro or Woocommerce subscription

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #28273

    Hi Johan,
    I can provide code for disabling the commenting.

    I currently do not use Paid Membership Pro or Woo Subscription, so, you will need to get some sample code for them to check the membership.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 11
    johan on #28285

    ok, so what exactly do I need to ask to them about the sample code? I have the plugins etc here..

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #28294

    Hi Johan,
    Please give them your membership level/subscription and ask them how to check if a user has one of the given subscriptions.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 11
    johan on #28297

    just posted this in pmpro, lets see what they tell

    My programmer ask how to check in pmpro
    – the code of membership level
    – the code how to check if a user has one of the given subscriptions

    wanna tweak buddypress with pmpro

  • Participant
    Level: Initiated
    Posts: 11
    johan on #28298

    This is what they replied me. What do u think?

    You are able to use the function pmpro_hasMembershipLevel or pmpro_getMembershipLevelForUser.

    When you need the code of a level, do you need to get the level object?

    A good place to start is to search the functions.php file for specifics – https://github.com/strangerstudios/paid-memberships-pro/blob/dev/includes/functions.php

    Please let me know what information you specifically need for the level code

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #28309

    Thank you. I will post an exmaple today.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 11
    johan on #28310

    looking forward to it Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #28339

    Hi Johan,
    Thank you for the patience.

    Please update the allowed level with correct ids and you may use the following in your bp-custom.pp

    
    
    add_filter( 'bp_activity_can_comment', function ( $can ) {
    
    	$logged_id = bp_loggedin_user_id();
    	if ( ! function_exists( 'pmpro_getMembershipLevelForUser' ) || ! is_user_logged_in() || bp_get_activity_user_id() == $logged_id || is_super_admin() ) {
    		return $can;
    	}
    
    	$level = pmpro_getMembershipLevelForUser( $logged_id );
    	if ( ! $level ) {
    		return false;
    	}
    
    	$allowed_levels = array( 1, 2 );
    
    	if ( ! in_array( $level->id, $allowed_levels ) ) {
    		$can = false;
    	}
    
    	return $can;
    
    } );
    
    

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved