Skip to:
Content
Pages
Categories
Search
Top
Bottom

unsubscribe a user from everything given a userid

  • @drksecret

    Participant

    I have bbpress and Ultimate Member/Subscriptions. When a user cancels their subscription, they are removed from ultimate member but not from bbpress and they are still receiving notifications. I have searched through this forum and found similar issues.
    I think I can fix it with AutomateWoo and a custom function. AutomateWoo can trigger the function. I just don’t know how to write a function that has a userid as an argument and then loops through unsubscribing this user.
    Can anyone help? I am sure this might help others as well.

    Thank you in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • @robin-w

    Moderator

    yes it seems this question has been asked before and I can’t see that anyone has written such a function.

    It is quite do-able, and I’ll see how easy it is to achieve

    @robin-w

    Moderator

    Just had a quick look in between other tasks, and totally untested, but this should work if it has no bugs

    function dsk_remove_all_subscriptions ($user_id) {
    	global $wpdb;
    	//first remove forum subscriptions
    	$forum=bbp_get_forum_post_type() ;
    	$forum_ids=$wpdb->get_col("select ID from $wpdb->posts where post_type = '$forum'") ;
    	foreach ($forum_ids as $forum_id) {
    		bbp_remove_user_forum_subscription( $user_id, $forum_id ) ;	
    	}
    	//then remove topic subscriptions
    	$topic=bbp_get_topic_post_type() ;
    	$topic_ids=$wpdb->get_col("select ID from $wpdb->posts where post_type = '$topic'") ;
    	foreach ($topic_ids as $topic_id) {
    		bbp_remove_user_topic_subscription( $user_id, $topic_id );
    	}
    }

    If you get it working, then please confirm or post back the final code.

    If you need further help do come back and I’ll see if I can help further

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar