~ubuntu-branches/debian/jessie/wordpress/jessie

« back to all changes in this revision

Viewing changes to wp-admin/includes/user.php

  • Committer: Package Import Robot
  • Author(s): Craig Small
  • Date: 2014-04-17 20:56:19 UTC
  • mfrom: (1.2.35)
  • Revision ID: package-import@ubuntu.com-20140417205619-nurbet6eho4yvwfv
Tags: 3.9+dfsg-1
* New upstream release
* 3.9 seems to handle different locations for plugins so the
  plugin directory handling patches have been cut back.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
/**
10
10
 * Creates a new user from the "Users" form using $_POST information.
11
11
 *
12
 
 * @since 2.0
 
12
 * @since 2.0.0
13
13
 *
14
14
 * @return null|WP_Error|int Null when adding user, WP_Error or User ID integer when no parameters.
15
15
 */
22
22
 *
23
23
 * Used on user-edit.php and profile.php to manage and process user options, passwords etc.
24
24
 *
25
 
 * @since 2.0
 
25
 * @since 2.0.0
26
26
 *
27
27
 * @param int $user_id Optional. User ID.
28
28
 * @return int user id of the updated user
193
193
 * only editors or authors. This filter allows admins to delegate
194
194
 * user management.
195
195
 *
196
 
 * @since 2.8
 
196
 * @since 2.8.0
197
197
 *
198
198
 * @return unknown
199
199
 */
268
268
 * @param int $reassign Optional. Reassign posts and links to new User ID.
269
269
 * @return bool True when finished.
270
270
 */
271
 
function wp_delete_user( $id, $reassign = 'novalue' ) {
 
271
function wp_delete_user( $id, $reassign = null ) {
272
272
        global $wpdb;
273
273
 
274
274
        $id = (int) $id;
277
277
        if ( !$user->exists() )
278
278
                return false;
279
279
 
 
280
        // Normalize $reassign to null or a user ID. 'novalue' was an older default.
 
281
        if ( 'novalue' === $reassign ) {
 
282
                $reassign = null;
 
283
        } elseif ( null !== $reassign ) {
 
284
                $reassign = (int) $reassign;
 
285
        }
 
286
 
280
287
        /**
281
288
         * Fires immediately before a user is deleted from the database.
282
289
         *
283
290
         * @since 2.0.0
284
291
         *
285
 
         * @param int $id User ID.
 
292
         * @param int      $id       ID of the user to delete.
 
293
         * @param int|null $reassign ID of the user to reassign posts and links to.
 
294
         *                           Default null, for no reassignment.
286
295
         */
287
 
        do_action( 'delete_user', $id );
 
296
        do_action( 'delete_user', $id, $reassign );
288
297
 
289
 
        if ( 'novalue' === $reassign || null === $reassign ) {
 
298
        if ( null === $reassign ) {
290
299
                $post_types_to_delete = array();
291
300
                foreach ( get_post_types( array(), 'objects' ) as $post_type ) {
292
301
                        if ( $post_type->delete_with_user ) {
320
329
                                wp_delete_link($link_id);
321
330
                }
322
331
        } else {
323
 
                $reassign = (int) $reassign;
324
332
                $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
325
333
                $wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) );
326
334
                if ( ! empty( $post_ids ) ) {
353
361
         *
354
362
         * @since 2.9.0
355
363
         *
356
 
         * @param int $id ID of the deleted user.
 
364
         * @param int      $id       ID of the deleted user.
 
365
         * @param int|null $reassign ID of the user to reassign posts and links to.
 
366
         *                           Default null, for no reassignment.
357
367
         */
358
 
        do_action( 'deleted_user', $id );
 
368
        do_action( 'deleted_user', $id, $reassign );
359
369
 
360
370
        return true;
361
371
}
420
430
        echo '<strong>' . __('Notice:') . '</strong> ';
421
431
        _e('You&rsquo;re using the auto-generated password for your account. Would you like to change it to something easier to remember?');
422
432
        echo '</p><p>';
423
 
        printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', get_edit_profile_url( get_current_user_id() ) . '#password' );
 
433
        printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', get_edit_profile_url() . '#password' );
424
434
        printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' );
425
435
        echo '</p></div>';
426
436
}