BuddyDev

Search

Replies

  • Participant
    Level: Initiated
    Posts: 4
    JG on #23645

    Ok perfect! Thank you both so much 🙂 Last question, with the Deactivate plugin, is there a way to fully hide a deactivated users profile from other users? For instance, if I type in the URL of a user, I can still see their profile, but there’s a message that says they’re “currently inactive”…. I’d rather make it so that the profile page isn’t visible at all, and instead have the user redirected to another page of my choosing. Is this possible?

  • Participant
    Level: Initiated
    Posts: 4
    JG on #23619

    Thanks so much Brajesh and Ravi! So Ravi, I think I see what you’re saying, but I have a few extra questions:

    Is it possible that a transaction could expire, but the user still has an active subscription? For instance, on a recurring subscription, i believe when one transaction expires, another is created. So there could be a potential race condition with the code you have above, if somehow the new transaction gets created before the old one is expired. So my thought is, we want to check if the user has any active subscriptions before deactivating them.

    As well, if I have my code in the functions.php file in my child theme, is it safe to assume that the “bp_account_deactivator()” will be available? Or rather, what is the scenario where that wouldn’t be instantiated already?

    Thanks again for your time!

  • Participant
    Level: Initiated
    Posts: 4
    JG on #23612

    Hi Brajesh! Yes that does help, thank you! I purchased the Deactivate Account Plugin today and am trying to use it to auto activate/deactivate accounts whenever MemberPress subscriptions change. I’m not sure if you know the answer to this (I’m reaching out to memberpress as well), but users that should be getting deactivated aren’t. If you have any experience using this plugin with MemberPress I would be most grateful for any suggestions. Thanks again!

    
    function listen_to_mepr_events($event) {
      $obj = $event->get_data();
      //$obj might be a MeprTransaction object or a MeprSubscription object
      if(!($obj instanceof MeprTransaction) && !($obj instanceof MeprSubscription)) {
        return; // nothing here to do if we're not dealing with a txn or sub
      }
      
      $member = $obj->user();
      
      //Make sure it's a valid user still
      if(!isset($member->ID) || !$member->ID) { return; }
        
      $subs = $member->active_product_subscriptions();
        
      if(!empty($subs)) {	
        //member is active on membership
    	 bp_account_deactivator()->set_active($member->ID);
      }
      else {
        //member is no longer active on this membership
        bp_account_deactivator()->set_inactive($member->ID);
      }
    }
    add_action('mepr-event-create', 'listen_to_mepr_events');
    
  • Participant
    Level: Initiated
    Posts: 4
    JG on #23604

    Hi Brajesh! Thank you so much for the quick response; much appreciated! If I were to use the BuddyPress Deactivate Account plugin, is there a way to prevent users from re-activating their own account if it’s been deactivated by an admin?

    Thanks again!