[wp-trac] [WordPress Trac] #27047: add a wp_save_user pluggable api for plugin to choose where to save user
WordPress Trac
noreply at wordpress.org
Fri Feb 7 09:26:05 UTC 2014
#27047: add a wp_save_user pluggable api for plugin to choose where to save user
-------------------------------+------------------------------
Reporter: fatihwk | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Users | Version: 3.8.1
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+------------------------------
Changes (by TobiasBg):
* keywords: => reporter-feedback
Old description:
> Index: user.php
> ===================================================================
> --- user.php (revision 26748)
> +++ user.php (working copy)
> @@ -1409,11 +1409,13 @@
> $data = wp_unslash( $data );
>
> if ( $update ) {
> - $wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
> - $user_id = (int) $ID;
> + //$wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
> + //$user_id = (int) $ID;
> + $user_id = (int)wp_save_user($data, compact( 'ID' ));
> } else {
> - $wpdb->insert( $wpdb->users, $data + compact(
> 'user_login' ) );
> - $user_id = (int) $wpdb->insert_id;
> + //$wpdb->insert( $wpdb->users, $data + compact(
> 'user_login' ) );
> + //$user_id = (int) $wpdb->insert_id;
> + $user_id = (int)wp_save_user($data + compact(
> 'user_login' ));
> }
>
> $user = new WP_User( $user_id );
> Index: pluggable.php
> ===================================================================
> --- pluggable.php (revision 26748)
> +++ pluggable.php (working copy)
> @@ -6,6 +6,30 @@
> * @package WordPress
> */
>
> +
> +
> +/**
> + * Save or update user to database
> + */
> +if (! function_exists('wp_save_user')):
> + function wp_save_user($data, $format = null)
> +{
> + extract( $format, EXTR_SKIP );
> + global $wpdb;
> + if ( !empty($ID) )
> + {
> + $wpdb->update($wpdb->users, $data, $format);
> + return $ID;
> + }
> + else
> + {
> + $wpdb->insert($wpdb->users, $data );
> + return $wpdb->insert_id;
> + }
> +}
> +endif;
> +
> +
> if ( !function_exists('wp_set_current_user') ) :
> /**
> * Changes the current user by ID or name.
New description:
[Original description removed as it was just the attached patches in plain
text]
--
Comment:
Thanks for your feature request.
Could you please elaborate and explain why and where this would helpful?
Couldn't this be achieved by changing the used database table in `$wpdb`
already?
Also, wouldn't this require changes in the functions that retrieve a user
from the database, too?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27047#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list