Skip to:
Content

BuddyPress.org

Ticket #5857: 5857.patch

File 5857.patch, 1.0 KB (added by imath, 10 years ago)
  • src/bp-blogs/bp-blogs-functions.php

    diff --git src/bp-blogs/bp-blogs-functions.php src/bp-blogs/bp-blogs-functions.php
    index ea472ad..d7f18a5 100644
    function bp_blogs_remove_data( $user_id ) { 
    14541454add_action( 'wpmu_delete_user',  'bp_blogs_remove_data' );
    14551455add_action( 'delete_user',       'bp_blogs_remove_data' );
    14561456add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' );
     1457
     1458/**
     1459 * Restore all blog associations for a given user
     1460 *
     1461 * @param  int $user_id ID whose blog data should be restored.
     1462 * @return bool|null Returns false on failure.
     1463 */
     1464function bp_blogs_restore_data( $user_id = 0 ) {
     1465        if ( ! is_multisite() ) {
     1466                return false;
     1467        }
     1468
     1469        // Get the user's blogs
     1470        $user_blogs = get_blogs_of_user( 2 );
     1471
     1472        if ( empty( $user_blogs ) ) {
     1473                return false;
     1474        }
     1475
     1476        $blogs = array_keys( $user_blogs );
     1477
     1478        foreach ( $blogs as $blog_id ) {
     1479                bp_blogs_record_blog( $blog_id, $user_id, true );
     1480        }
     1481}
     1482add_action( 'bp_make_ham_user', 'bp_blogs_restore_data', 10, 1 );