Example #1
0
/**
 * Remove user and optionally reassign posts and links to another user.
 *
 * If the $reassign parameter is not assigned to an User ID, then all posts will
 * be deleted of that user. The action 'delete_user' that is passed the User ID
 * being deleted will be run after the posts are either reassigned or deleted.
 * The user meta will also be deleted that are for that User ID.
 *
 * @since 2.0.0
 *
 * @param int $id User ID.
 * @param int $reassign Optional. Reassign posts and links to new User ID.
 * @return bool True when finished.
 */
function nxt_delete_user($id, $reassign = 'novalue')
{
    global $nxtdb;
    $id = (int) $id;
    // allow for transaction statement
    do_action('delete_user', $id);
    if ('novalue' === $reassign || null === $reassign) {
        $post_ids = $nxtdb->get_col($nxtdb->prepare("SELECT ID FROM {$nxtdb->posts} WHERE post_author = %d", $id));
        if ($post_ids) {
            foreach ($post_ids as $post_id) {
                nxt_delete_post($post_id);
            }
        }
        // Clean links
        $link_ids = $nxtdb->get_col($nxtdb->prepare("SELECT link_id FROM {$nxtdb->links} WHERE link_owner = %d", $id));
        if ($link_ids) {
            foreach ($link_ids as $link_id) {
                nxt_delete_link($link_id);
            }
        }
    } else {
        $reassign = (int) $reassign;
        $nxtdb->update($nxtdb->posts, array('post_author' => $reassign), array('post_author' => $id));
        $nxtdb->update($nxtdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
    }
    clean_user_cache($id);
    // FINALLY, delete user
    if (!is_multisite()) {
        $nxtdb->query($nxtdb->prepare("DELETE FROM {$nxtdb->usermeta} WHERE user_id = %d", $id));
        $nxtdb->query($nxtdb->prepare("DELETE FROM {$nxtdb->users} WHERE ID = %d", $id));
    } else {
        $level_key = $nxtdb->get_blog_prefix() . 'capabilities';
        // nxtmu site admins don't have user_levels
        $nxtdb->query("DELETE FROM {$nxtdb->usermeta} WHERE user_id = {$id} AND meta_key = '{$level_key}'");
    }
    // allow for commit transaction
    do_action('deleted_user', $id);
    return true;
}
Example #2
0
 */
/** Load NXTClass Administration Bootstrap */
require_once 'admin.php';
if (!current_user_can('manage_links')) {
    nxt_die(__('You do not have sufficient permissions to edit the links for this site.'));
}
$nxt_list_table = _get_list_table('nxt_Links_List_Table');
// Handle bulk deletes
$doaction = $nxt_list_table->current_action();
if ($doaction && isset($_REQUEST['linkcheck'])) {
    check_admin_referer('bulk-bookmarks');
    if ('delete' == $doaction) {
        $bulklinks = (array) $_REQUEST['linkcheck'];
        foreach ($bulklinks as $link_id) {
            $link_id = (int) $link_id;
            nxt_delete_link($link_id);
        }
        nxt_redirect(add_query_arg('deleted', count($bulklinks), admin_url('link-manager.php')));
        exit;
    }
} elseif (!empty($_GET['_nxt_http_referer'])) {
    nxt_redirect(remove_query_arg(array('_nxt_http_referer', '_nxtnonce'), stripslashes($_SERVER['REQUEST_URI'])));
    exit;
}
$nxt_list_table->prepare_items();
$title = __('Links');
$this_file = $parent_file = 'link-manager.php';
get_current_screen()->add_help_tab(array('id' => 'overview', 'title' => __('Overview'), 'content' => '<p>' . sprintf(__('You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the NXTClass community are included as examples.'), 'widgets.php') . '</p>' . '<p>' . __('Links may be separated into Link Categories; these are different than the categories used on your posts.') . '</p>' . '<p>' . __('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.') . '</p>'));
get_current_screen()->add_help_tab(array('id' => 'deleting-links', 'title' => __('Deleting Links'), 'content' => '<p>' . __('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.') . '</p>'));
get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="http://codex.nxtclass.org/Links_Screen" target="_blank">Documentation on Managing Links</a>') . '</p>' . '<p>' . __('<a href="http://nxtclass.org/support/" target="_blank">Support Forums</a>') . '</p>');
include_once './admin-header.php';
Example #3
0
     if (nxt_delete_term($tag_id, $taxonomy)) {
         die('1');
     } else {
         die('0');
     }
     break;
 case 'delete-link':
     check_ajax_referer("delete-bookmark_{$id}");
     if (!current_user_can('manage_links')) {
         die('-1');
     }
     $link = get_bookmark($id);
     if (!$link || is_nxt_error($link)) {
         die('1');
     }
     if (nxt_delete_link($id)) {
         die('1');
     } else {
         die('0');
     }
     break;
 case 'delete-meta':
     check_ajax_referer("delete-meta_{$id}");
     if (!($meta = get_metadata_by_mid('post', $id))) {
         die('1');
     }
     if (is_protected_meta($meta->meta_key, 'post') || !current_user_can('delete_post_meta', $meta->post_id, $meta->meta_key)) {
         die('-1');
     }
     if (delete_meta($meta->meta_id)) {
         die('1');
Example #4
0
function nxtmu_delete_user($id)
{
    global $nxtdb;
    $id = (int) $id;
    do_action('nxtmu_delete_user', $id);
    $blogs = get_blogs_of_user($id);
    if (!empty($blogs)) {
        foreach ($blogs as $blog) {
            switch_to_blog($blog->userblog_id);
            remove_user_from_blog($id, $blog->userblog_id);
            $post_ids = $nxtdb->get_col($nxtdb->prepare("SELECT ID FROM {$nxtdb->posts} WHERE post_author = %d", $id));
            foreach ((array) $post_ids as $post_id) {
                nxt_delete_post($post_id);
            }
            // Clean links
            $link_ids = $nxtdb->get_col($nxtdb->prepare("SELECT link_id FROM {$nxtdb->links} WHERE link_owner = %d", $id));
            if ($link_ids) {
                foreach ($link_ids as $link_id) {
                    nxt_delete_link($link_id);
                }
            }
            restore_current_blog();
        }
    }
    $nxtdb->query($nxtdb->prepare("DELETE FROM {$nxtdb->users} WHERE ID = %d", $id));
    $nxtdb->query($nxtdb->prepare("DELETE FROM {$nxtdb->usermeta} WHERE user_id = %d", $id));
    clean_user_cache($id);
    // allow for commit transaction
    do_action('deleted_user', $id);
    return true;
}
 /**
  * Deletes plugin link from Blogroll
  *
  * @return void
  */
 function link_delete()
 {
     $bookmarks = get_bookmarks();
     $link_id = 0;
     foreach ($bookmarks as $bookmark) {
         if ($bookmark->link_url == W3TC_LINK_URL) {
             $link_id = $bookmark->link_id;
             break;
         }
     }
     if ($link_id) {
         require_once ABSPATH . 'nxt-admin/includes/bookmark.php';
         nxt_delete_link($link_id);
     }
 }