Replies
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>
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,
MwaleHello 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,
MwaleHi 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,
MwaleHi 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,
MwaleHi 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