BuddyDev

Search

Replies

  • Participant
    Level: Enlightened
    Posts: 21
    Mwale on #17191

    Hey Brajesh!

    Thank you so much! Everything works fine thanks to you 🙂

    I have also changed the condition to ‘function_exists’, thanks!

    Kind regards,
    Mwale

  • Participant
    Level: Enlightened
    Posts: 21
    Mwale on #17151

    Hi Ravi,

    Thank you for your reply 🙂

    Unfortunately, that leads to a fatal error ‘undefined function’. I am adding it like so:

    <a id="user-messages" href="/messages/" class="msg">Messages <span class="alert_count"><?php if( class_exists( 'Buddypress' ) ) {echo messages_get_unread_count( $user_id = 0 );} ?></span></a>

  • Participant
    Level: Enlightened
    Posts: 21
    Mwale on #14861

    Hi Brajesh,

    I want to say thank you very much for helping me on this topic. Unfortunately I have not been able to make the best(more efficient) solution work, so I am using the inefficient code here: https://buddydev.com/support/forums/topic/how-to-remove-buddypress-user-from-all-groups/#post-14107 . This is the solution I am currently using. As such I am marking this topic as solved, thanks again.

    Kind regards,
    Mwale

  • Participant
    Level: Enlightened
    Posts: 21
    Mwale on #14179

    Hi Brajesh,

    Thanks for the advice. I checked the error. I fixed it simply by moving code from custom-plugin.php to functions.php .

    The site is not crashing anymore, but the code doesn’t seem to be doing what it is supposed to do.

    Kind regards,
    Mwale

  • Participant
    Level: Enlightened
    Posts: 21
    Mwale on #14157

    Hello Brajesh,

    Unfortunately that leads to a white blank screen. But I have a feeling that we almost have it. What could be the issue?

    The entire code I added is this:

    function mwale_remove_from_group_on_membership_deactivate( $event, $subscription ) {
    	$member = $subscription->get_member();
    	$user   = $member->get_user();
    	if ( ! $user || is_a( $user, 'WP_User' ) ) {
    		return;
    	}
    
    	groups_remove_data_for_user( $user->ID );
    
    }
    
    add_action( 'ms_subscription_status-' . MS_Model_Relationship::STATUS_EXPIRED, 'mwale_remove_from_group_on_membership_deactivate', 10, 2 );

    Warm regards,
    Mwale

  • Participant
    Level: Enlightened
    Posts: 21
    Mwale on #14144

    Hi Brajesh,

    the plugin support said to use something like this:

    function ms_subscription_expired_action( $subscription, $membership, $member ){
        //Do stuff
    }
    add_action( 'ms_subscription_status-' . MS_Model_Relationship::STATUS_EXPIRED, 'ms_subscription_expired_action', 10, 3 );

    Kind regards,
    Mwale

  • Participant
    Level: Enlightened
    Posts: 21
    Mwale on #14126

    Hi Brajesh,

    Thanks for having a look at the code. I have a feeling that this happens via a cron job. I am waiting for response from developers I will let you know, thanks again.

    Kind regards,
    Mwale

  • Participant
    Level: Enlightened
    Posts: 21
    Mwale on #14107

    Hi Brajesh,

    thank you, thank you, thank you so much for your assistance!!!! * 100 🙂

    I almost have a solution and will really appreciate more feedback.

    As you know I want to remove from groups all members with id=943 and no membership. The plugin developers provided this: https://gist.github.com/wpmudev-sls/e3d62705d8caabe74fc410eb1e2e1c7e

    I added this id but nothing happens:

    $membership_ids = array(943);

    Should I add the code you mentioned above? What else do I need to change?

    Kind regards,
    Mwale

  • Participant
    Level: Enlightened
    Posts: 21
    Mwale on #14023

    Hi Brajesh,

    Thanks for your reply.

    Unfortunately the above did not work. I also tried the following which did not work either 🙁 :

    
        function mwale_remove_from_group_on_membership_deactivate( $event, $subscription ) {
        	$member = MS_Model_Member::get_current_member();
    
    if ( $member->has_membership( 943 ) ) {
        return;
    }
    
        	groups_remove_data_for_user( $user->ID );
    
        }
    
        add_action( 'ms_model_event_deactivated', 'mwale_remove_from_group_on_membership_deactivate', 10, 2 );

    I sent a message to Membership 2 author and I am waiting for a reply.

    In the mean time I found this article: https://premium.wpmudev.org/forums/topic/how-to-check-if-a-user-belongs-to-a-subscription-level

    Kind regards,
    Mwale

  • Participant
    Level: Enlightened
    Posts: 21
    Mwale on #13859

    Hi Brajesh,

    Thank you so much Brajesh :)) ! Please help me to put the two pieces of code together. I am not very good with PHP.

    Kind regards,
    Mwale.