<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: ¿Cómo integrar phpBB3 con tu sitio?</title>
	<atom:link href="http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38/feed" rel="self" type="application/rss+xml" />
	<link>http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38</link>
	<description>desarrollo, comunidad y monetización</description>
	<pubDate>Fri, 21 Nov 2008 08:57:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Dani</title>
		<link>http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38#comment-503</link>
		<dc:creator>Dani</dc:creator>
		<pubDate>Mon, 25 Aug 2008 12:28:45 +0000</pubDate>
		<guid isPermaLink="false">http://pragone.com/?p=38#comment-503</guid>
		<description>Al crear ese módulo lo que se está haciendo es ingresar a los foros (desde el formulario de login de los foros) y comprobar si el usuario que ha ingresado está registrado en el otro sitio. Si está registrado y son correctos los datos accede a los foros. Y si ese usuario no está registrado en los foros se agregan sus datos a la base de datos de los foros ¿algo así no?.

pero y como se hace para que el usuario ingrese desde el login de la web y después si entra en los foros ya se encuentre identificado sin tener que ingresar sus datos otra vez?</description>
		<content:encoded><![CDATA[<p>Al crear ese módulo lo que se está haciendo es ingresar a los foros (desde el formulario de login de los foros) y comprobar si el usuario que ha ingresado está registrado en el otro sitio. Si está registrado y son correctos los datos accede a los foros. Y si ese usuario no está registrado en los foros se agregan sus datos a la base de datos de los foros ¿algo así no?.</p>
<p>pero y como se hace para que el usuario ingrese desde el login de la web y después si entra en los foros ya se encuentre identificado sin tener que ingresar sus datos otra vez?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pragone</title>
		<link>http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38#comment-108</link>
		<dc:creator>pragone</dc:creator>
		<pubDate>Sun, 08 Jun 2008 13:02:49 +0000</pubDate>
		<guid isPermaLink="false">http://pragone.com/?p=38#comment-108</guid>
		<description>Hola,
Ya he creado un nuevo post desde el que enlazaré a las distintas formas de integración de phpBB3 con un sitio.

Visita: http://pragone.com/proyectos/integracion-de-phpbb3-con-tu-sitio/47</description>
		<content:encoded><![CDATA[<p>Hola,<br />
Ya he creado un nuevo post desde el que enlazaré a las distintas formas de integración de phpBB3 con un sitio.</p>
<p>Visita: <a href="http://pragone.com/proyectos/integracion-de-phpbb3-con-tu-sitio/47" rel="nofollow">http://pragone.com/proyectos/integracion-de-phpbb3-con-tu-sitio/47</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Integración de phpBB3 con tu sitio &#124; pragone.com</title>
		<link>http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38#comment-106</link>
		<dc:creator>Integración de phpBB3 con tu sitio &#124; pragone.com</dc:creator>
		<pubDate>Sun, 08 Jun 2008 12:43:49 +0000</pubDate>
		<guid isPermaLink="false">http://pragone.com/?p=38#comment-106</guid>
		<description>[...] Hace un tiempo, escribí un artículo sobre cómo integrar phpBB3 con tu sitio. [...]</description>
		<content:encoded><![CDATA[<p>[...] Hace un tiempo, escribí un artículo sobre cómo integrar phpBB3 con tu sitio. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lundra</title>
		<link>http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38#comment-105</link>
		<dc:creator>Lundra</dc:creator>
		<pubDate>Sat, 07 Jun 2008 17:10:37 +0000</pubDate>
		<guid isPermaLink="false">http://pragone.com/?p=38#comment-105</guid>
		<description>pragone mil gracias por tu contestacion tomate el tiempo que quieras, en internet faltan mas personas como tu, gracias enserio esperare esas formas :) jeje</description>
		<content:encoded><![CDATA[<p>pragone mil gracias por tu contestacion tomate el tiempo que quieras, en internet faltan mas personas como tu, gracias enserio esperare esas formas <img src='http://pragone.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> jeje</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pragone</title>
		<link>http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38#comment-104</link>
		<dc:creator>pragone</dc:creator>
		<pubDate>Sat, 07 Jun 2008 14:24:13 +0000</pubDate>
		<guid isPermaLink="false">http://pragone.com/?p=38#comment-104</guid>
		<description>Lundra,

Ahora apenas es que tengo un tiempo para verlo. Entre hoy y mañana estaré escribiendo un nuevo post con distintas formas de integración. Lo que tu buscas es diferente de la integración que yo pongo en este post.... básicamente porque crear un módulo de autenticación es una forma "pasiva" de integración (es decir requiere un primer login en el phpBB3 para que el usuario se copie). Lo que tu quieres es una integración más "activa", es decir que cuando se cree el usuario en WordPress, automáticamente ya se cree el usuario en phpBB3.

Es diferente y requiere su estudio. Voy a escribir al respecto en otro post.</description>
		<content:encoded><![CDATA[<p>Lundra,</p>
<p>Ahora apenas es que tengo un tiempo para verlo. Entre hoy y mañana estaré escribiendo un nuevo post con distintas formas de integración. Lo que tu buscas es diferente de la integración que yo pongo en este post&#8230;. básicamente porque crear un módulo de autenticación es una forma &#8220;pasiva&#8221; de integración (es decir requiere un primer login en el phpBB3 para que el usuario se copie). Lo que tu quieres es una integración más &#8220;activa&#8221;, es decir que cuando se cree el usuario en WordPress, automáticamente ya se cree el usuario en phpBB3.</p>
<p>Es diferente y requiere su estudio. Voy a escribir al respecto en otro post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pragone</title>
		<link>http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38#comment-103</link>
		<dc:creator>pragone</dc:creator>
		<pubDate>Sat, 07 Jun 2008 14:20:45 +0000</pubDate>
		<guid isPermaLink="false">http://pragone.com/?p=38#comment-103</guid>
		<description>Urover,

Verás, para eso realmente lo que necesitas no es un método de autenticación particular.

Los métodos de autenticación lo que te ofrecen son formas de verificar la información de Username y Password que un usuario coloca cuando se está identificando en el phpBB3. Si no quieres que se tenga que volver a loguear, entonces lo que necesitas es algo que setee las cookies de sesión para el phpBB3.

Voy a escribir algo al respecto en un post siguiente.</description>
		<content:encoded><![CDATA[<p>Urover,</p>
<p>Verás, para eso realmente lo que necesitas no es un método de autenticación particular.</p>
<p>Los métodos de autenticación lo que te ofrecen son formas de verificar la información de Username y Password que un usuario coloca cuando se está identificando en el phpBB3. Si no quieres que se tenga que volver a loguear, entonces lo que necesitas es algo que setee las cookies de sesión para el phpBB3.</p>
<p>Voy a escribir algo al respecto en un post siguiente.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lundra</title>
		<link>http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38#comment-102</link>
		<dc:creator>Lundra</dc:creator>
		<pubDate>Wed, 04 Jun 2008 10:51:14 +0000</pubDate>
		<guid isPermaLink="false">http://pragone.com/?p=38#comment-102</guid>
		<description>No pasa nada pragone :D, gracias por mirarlo ;D esperare ansioso tu respuesta jeje</description>
		<content:encoded><![CDATA[<p>No pasa nada pragone :D, gracias por mirarlo ;D esperare ansioso tu respuesta jeje</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: urover</title>
		<link>http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38#comment-101</link>
		<dc:creator>urover</dc:creator>
		<pubDate>Wed, 04 Jun 2008 07:42:56 +0000</pubDate>
		<guid isPermaLink="false">http://pragone.com/?p=38#comment-101</guid>
		<description>Hola Pragone, verás mi duda es la siguiente: tengo un sitio donde el usuario ha de logearse para entrar, y una vez dentro quiero que pueda usar el phpBB3, PERO sin tener que volver a loguearse en el phpBB, ¿qué método de autenticación debo usar para conseguir para eso? No estoy seguro si es LDAP o Apache, estoy desesperado la verdad! Muchas gracias y has hecho una gran aportación!</description>
		<content:encoded><![CDATA[<p>Hola Pragone, verás mi duda es la siguiente: tengo un sitio donde el usuario ha de logearse para entrar, y una vez dentro quiero que pueda usar el phpBB3, PERO sin tener que volver a loguearse en el phpBB, ¿qué método de autenticación debo usar para conseguir para eso? No estoy seguro si es LDAP o Apache, estoy desesperado la verdad! Muchas gracias y has hecho una gran aportación!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pragone</title>
		<link>http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38#comment-100</link>
		<dc:creator>pragone</dc:creator>
		<pubDate>Wed, 04 Jun 2008 07:10:41 +0000</pubDate>
		<guid isPermaLink="false">http://pragone.com/?p=38#comment-100</guid>
		<description>Hola Lundra,

Disculpa la tardanza... es que en el curro he estado un poco con mil cosas. Trataré de verlo hoy</description>
		<content:encoded><![CDATA[<p>Hola Lundra,</p>
<p>Disculpa la tardanza&#8230; es que en el curro he estado un poco con mil cosas. Trataré de verlo hoy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lundra</title>
		<link>http://pragone.com/proyectos/como-integrar-phpbb3-con-tu-sitio/38#comment-99</link>
		<dc:creator>Lundra</dc:creator>
		<pubDate>Tue, 03 Jun 2008 12:15:50 +0000</pubDate>
		<guid isPermaLink="false">http://pragone.com/?p=38#comment-99</guid>
		<description>Te pongo el archivo registration.php de wordpress haber si tu eres capaz de decirme donde e de pone un codigo para que inserte el nuevo usuario en la tabla de usuarios de phpbb por q yo no se..., aclaro que tengo el wordpress y el phpbb en la misma base de datos.

ID;
	} else {
		return null;
	}
}

/**
 * email_exists() - Checks whether the given email exists.
 *
 * @since 2.1.0
 * @uses $wpdb
 *
 * @param string $email Email.
 * @return bool&#124;int The user's ID on success, and false on failure.
 */
function email_exists( $email ) {
	if ( $user = get_user_by_email($email) )
		return $user-&#62;ID;

	return false;
}

/**
 * validate_username() - Checks whether an username is valid.
 *
 * @since 2.0.1
 * @uses apply_filters() Calls 'validate_username' hook on $valid check and $username as parameters
 *
 * @param string $username Username.
 * @return bool Whether username given is valid
 */
function validate_username( $username ) {
	$sanitized = sanitize_user( $username, true );
	$valid = ( $sanitized == $username );
	return apply_filters( 'validate_username', $valid, $username );
}

/**
 * wp_insert_user() - Insert an user into the database.
 *
 * Can update a current user or insert a new user based on whether
 * the user's ID is present.
 *
 * Can be used to update the user's info (see below), set the user's
 * role, and set the user's preference on whether they want the rich
 * editor on.
 *
 * Most of the $userdata array fields have filters associated with
 * the values. The exceptions are 'rich_editing', 'role', 'jabber',
 * 'aim', 'yim', 'user_registered', and 'ID'. The filters have the
 * prefix 'pre_user_' followed by the field name. An example using
 * 'description' would have the filter called, 'pre_user_description'
 * that can be hooked into.
 *
 * The $userdata array can contain the following fields:
 * 'ID' - An integer that will be used for updating an existing user.
 * 'user_pass' - A string that contains the plain text password for the user.
 * 'user_login' - A string that contains the user's username for logging in.
 * 'user_nicename' - A string that contains a nicer looking name for the user.
 *		The default is the user's username.
 * 'user_url' - A string containing the user's URL for the user's web site.
 * 'user_email' - A string containing the user's email address.
 * 'display_name' - A string that will be shown on the site. Defaults to user's username.
 *		It is likely that you will want to change this, for both appearance and security
 *		through obscurity (that is if you don't use and delete the default 'admin' user).
 * 'nickname' - The user's nickname, defaults to the user's username.
 * 'first_name' - The user's first name.
 * 'last_name' - The user's last name.
 * 'description' - A string containing content about the user.
 * 'rich_editing' - A string for whether to enable the rich editor or not. False if not
 *		empty.
 * 'user_registered' - The date the user registered. Format is 'Y-m-d H:i:s'.
 * 'role' - A string used to set the user's role.
 * 'jabber' - User's Jabber account.
 * 'aim' - User's AOL IM account.
 * 'yim' - User's Yahoo IM account.
 *
 * @since 2.0.0
 * @uses $wpdb WordPress database layer.
 * @uses apply_filters() Calls filters for most of the $userdata fields with the prefix 'pre_user'. See note above.
 * @uses do_action() Calls 'profile_update' hook when updating giving the user's ID
 * @uses do_action() Calls 'user_register' hook when creating a new user giving the user's ID
 *
 * @param array $userdata An array of user data.
 * @return int The newly created user's ID.
 */
function wp_insert_user($userdata) {
	global $wpdb;

	extract($userdata, EXTR_SKIP);

	// Are we updating or creating?
	if ( !empty($ID) ) {
		$ID = (int) $ID;
		$update = true;
	} else {
		$update = false;
		// Hash the password
		$user_pass = wp_hash_password($user_pass);
	}

	$user_login = sanitize_user($user_login, true);
	$user_login = apply_filters('pre_user_login', $user_login);

	if ( empty($user_nicename) )
		$user_nicename = sanitize_title( $user_login );
	$user_nicename = apply_filters('pre_user_nicename', $user_nicename);

	if ( empty($user_url) )
		$user_url = '';
	$user_url = apply_filters('pre_user_url', $user_url);

	if ( empty($user_email) )
		$user_email = '';
	$user_email = apply_filters('pre_user_email', $user_email);

	if ( empty($display_name) )
		$display_name = $user_login;
	$display_name = apply_filters('pre_user_display_name', $display_name);

	if ( empty($nickname) )
		$nickname = $user_login;
	$nickname = apply_filters('pre_user_nickname', $nickname);

	if ( empty($first_name) )
		$first_name = '';
	$first_name = apply_filters('pre_user_first_name', $first_name);

	if ( empty($last_name) )
		$last_name = '';
	$last_name = apply_filters('pre_user_last_name', $last_name);

	if ( empty($description) )
		$description = '';
	$description = apply_filters('pre_user_description', $description);

	if ( empty($rich_editing) )
		$rich_editing = 'true';

	if ( empty($admin_color) )
		$admin_color = 'fresh';
	$admin_color = preg_replace('&#124;[^a-z0-9 _.\-@]&#124;i', '', $admin_color);

	if ( empty($user_registered) )
		$user_registered = gmdate('Y-m-d H:i:s');

	$data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
	$data = stripslashes_deep( $data );

	if ( $update ) {
		$wpdb-&#62;update( $wpdb-&#62;users, $data, compact( 'ID' ) );
		$user_id = (int) $ID;
	} else {
		$wpdb-&#62;insert( $wpdb-&#62;users, $data + compact( 'user_login' ) );
		$user_id = (int) $wpdb-&#62;insert_id;
	}

	update_usermeta( $user_id, 'first_name', $first_name);
	update_usermeta( $user_id, 'last_name', $last_name);
	update_usermeta( $user_id, 'nickname', $nickname );
	update_usermeta( $user_id, 'description', $description );
	update_usermeta( $user_id, 'jabber', $jabber );
	update_usermeta( $user_id, 'aim', $aim );
	update_usermeta( $user_id, 'yim', $yim );
	update_usermeta( $user_id, 'rich_editing', $rich_editing);
	update_usermeta( $user_id, 'admin_color', $admin_color);

	if ( $update &#38;&#38; isset($role) ) {
		$user = new WP_User($user_id);
		$user-&#62;set_role($role);
	}

	if ( !$update ) {
		$user = new WP_User($user_id);
		$user-&#62;set_role(get_option('default_role'));
	}

	wp_cache_delete($user_id, 'users');
	wp_cache_delete($user_login, 'userlogins');

	if ( $update )
		do_action('profile_update', $user_id);
	else
		do_action('user_register', $user_id);

	return $user_id;
}

/**
 * wp_update_user() - Update an user in the database
 *
 * It is possible to update a user's password by specifying the
 * 'user_pass' value in the $userdata parameter array.
 *
 * If $userdata does not contain an 'ID' key, then a new user
 * will be created and the new user's ID will be returned.
 *
 * If current user's password is being updated, then the cookies
 * will be cleared.
 *
 * @since 2.0.0
 * @see wp_insert_user() For what fields can be set in $userdata
 * @uses wp_insert_user() Used to update existing user or add new one if user doesn't exist already
 *
 * @param array $userdata An array of user data.
 * @return int The updated user's ID.
 */
function wp_update_user($userdata) {
	$ID = (int) $userdata['ID'];

	// First, get all of the original fields
	$user = get_userdata($ID);

	// Escape data pulled from DB.
	$user = add_magic_quotes(get_object_vars($user));

	// If password is changing, hash it now.
	if ( ! empty($userdata['user_pass']) ) {
		$plaintext_pass = $userdata['user_pass'];
		$userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
	}

	// Merge old and new fields with new fields overwriting old ones.
	$userdata = array_merge($user, $userdata);
	$user_id = wp_insert_user($userdata);

	// Update the cookies if the password changed.
	$current_user = wp_get_current_user();
	if ( $current_user-&#62;id == $ID ) {
		if ( isset($plaintext_pass) ) {
			wp_clear_auth_cookie();
			wp_set_auth_cookie($ID);
		}
	}

	return $user_id;
}

/**
 * wp_create_user() - A simpler way of inserting an user into the database.
 *
 * Creates a new user with just the username, password, and email. For a more
 * detail creation of a user, use wp_insert_user() to specify more infomation.
 *
 * @since 2.0.0
 * @see wp_insert_user() More complete way to create a new user
 * @uses $wpdb Escapes $username and $email parameters
 *
 * @param string $username The user's username.
 * @param string $password The user's password.
 * @param string $email The user's email (optional).
 * @return int The new user's ID.
 */
function wp_create_user($username, $password, $email = '') {
	global $wpdb;

	$user_login = $wpdb-&#62;escape($username);
	$user_email = $wpdb-&#62;escape($email);
	$user_pass = $password;

	$userdata = compact('user_login', 'user_email', 'user_pass');
	return wp_insert_user($userdata);
}

?&#62;</description>
		<content:encoded><![CDATA[<p>Te pongo el archivo registration.php de wordpress haber si tu eres capaz de decirme donde e de pone un codigo para que inserte el nuevo usuario en la tabla de usuarios de phpbb por q yo no se&#8230;, aclaro que tengo el wordpress y el phpbb en la misma base de datos.</p>
<p>ID;<br />
	} else {<br />
		return null;<br />
	}<br />
}</p>
<p>/**<br />
 * email_exists() - Checks whether the given email exists.<br />
 *<br />
 * @since 2.1.0<br />
 * @uses $wpdb<br />
 *<br />
 * @param string $email Email.<br />
 * @return bool|int The user&#8217;s ID on success, and false on failure.<br />
 */<br />
function email_exists( $email ) {<br />
	if ( $user = get_user_by_email($email) )<br />
		return $user-&gt;ID;</p>
<p>	return false;<br />
}</p>
<p>/**<br />
 * validate_username() - Checks whether an username is valid.<br />
 *<br />
 * @since 2.0.1<br />
 * @uses apply_filters() Calls &#8216;validate_username&#8217; hook on $valid check and $username as parameters<br />
 *<br />
 * @param string $username Username.<br />
 * @return bool Whether username given is valid<br />
 */<br />
function validate_username( $username ) {<br />
	$sanitized = sanitize_user( $username, true );<br />
	$valid = ( $sanitized == $username );<br />
	return apply_filters( &#8216;validate_username&#8217;, $valid, $username );<br />
}</p>
<p>/**<br />
 * wp_insert_user() - Insert an user into the database.<br />
 *<br />
 * Can update a current user or insert a new user based on whether<br />
 * the user&#8217;s ID is present.<br />
 *<br />
 * Can be used to update the user&#8217;s info (see below), set the user&#8217;s<br />
 * role, and set the user&#8217;s preference on whether they want the rich<br />
 * editor on.<br />
 *<br />
 * Most of the $userdata array fields have filters associated with<br />
 * the values. The exceptions are &#8216;rich_editing&#8217;, &#8216;role&#8217;, &#8216;jabber&#8217;,<br />
 * &#8216;aim&#8217;, &#8216;yim&#8217;, &#8216;user_registered&#8217;, and &#8216;ID&#8217;. The filters have the<br />
 * prefix &#8216;pre_user_&#8217; followed by the field name. An example using<br />
 * &#8216;description&#8217; would have the filter called, &#8216;pre_user_description&#8217;<br />
 * that can be hooked into.<br />
 *<br />
 * The $userdata array can contain the following fields:<br />
 * &#8216;ID&#8217; - An integer that will be used for updating an existing user.<br />
 * &#8216;user_pass&#8217; - A string that contains the plain text password for the user.<br />
 * &#8216;user_login&#8217; - A string that contains the user&#8217;s username for logging in.<br />
 * &#8216;user_nicename&#8217; - A string that contains a nicer looking name for the user.<br />
 *		The default is the user&#8217;s username.<br />
 * &#8216;user_url&#8217; - A string containing the user&#8217;s URL for the user&#8217;s web site.<br />
 * &#8216;user_email&#8217; - A string containing the user&#8217;s email address.<br />
 * &#8216;display_name&#8217; - A string that will be shown on the site. Defaults to user&#8217;s username.<br />
 *		It is likely that you will want to change this, for both appearance and security<br />
 *		through obscurity (that is if you don&#8217;t use and delete the default &#8216;admin&#8217; user).<br />
 * &#8216;nickname&#8217; - The user&#8217;s nickname, defaults to the user&#8217;s username.<br />
 * &#8216;first_name&#8217; - The user&#8217;s first name.<br />
 * &#8216;last_name&#8217; - The user&#8217;s last name.<br />
 * &#8216;description&#8217; - A string containing content about the user.<br />
 * &#8216;rich_editing&#8217; - A string for whether to enable the rich editor or not. False if not<br />
 *		empty.<br />
 * &#8216;user_registered&#8217; - The date the user registered. Format is &#8216;Y-m-d H:i:s&#8217;.<br />
 * &#8216;role&#8217; - A string used to set the user&#8217;s role.<br />
 * &#8216;jabber&#8217; - User&#8217;s Jabber account.<br />
 * &#8216;aim&#8217; - User&#8217;s AOL IM account.<br />
 * &#8216;yim&#8217; - User&#8217;s Yahoo IM account.<br />
 *<br />
 * @since 2.0.0<br />
 * @uses $wpdb WordPress database layer.<br />
 * @uses apply_filters() Calls filters for most of the $userdata fields with the prefix &#8216;pre_user&#8217;. See note above.<br />
 * @uses do_action() Calls &#8216;profile_update&#8217; hook when updating giving the user&#8217;s ID<br />
 * @uses do_action() Calls &#8216;user_register&#8217; hook when creating a new user giving the user&#8217;s ID<br />
 *<br />
 * @param array $userdata An array of user data.<br />
 * @return int The newly created user&#8217;s ID.<br />
 */<br />
function wp_insert_user($userdata) {<br />
	global $wpdb;</p>
<p>	extract($userdata, EXTR_SKIP);</p>
<p>	// Are we updating or creating?<br />
	if ( !empty($ID) ) {<br />
		$ID = (int) $ID;<br />
		$update = true;<br />
	} else {<br />
		$update = false;<br />
		// Hash the password<br />
		$user_pass = wp_hash_password($user_pass);<br />
	}</p>
<p>	$user_login = sanitize_user($user_login, true);<br />
	$user_login = apply_filters(&#8217;pre_user_login&#8217;, $user_login);</p>
<p>	if ( empty($user_nicename) )<br />
		$user_nicename = sanitize_title( $user_login );<br />
	$user_nicename = apply_filters(&#8217;pre_user_nicename&#8217;, $user_nicename);</p>
<p>	if ( empty($user_url) )<br />
		$user_url = &#8221;;<br />
	$user_url = apply_filters(&#8217;pre_user_url&#8217;, $user_url);</p>
<p>	if ( empty($user_email) )<br />
		$user_email = &#8221;;<br />
	$user_email = apply_filters(&#8217;pre_user_email&#8217;, $user_email);</p>
<p>	if ( empty($display_name) )<br />
		$display_name = $user_login;<br />
	$display_name = apply_filters(&#8217;pre_user_display_name&#8217;, $display_name);</p>
<p>	if ( empty($nickname) )<br />
		$nickname = $user_login;<br />
	$nickname = apply_filters(&#8217;pre_user_nickname&#8217;, $nickname);</p>
<p>	if ( empty($first_name) )<br />
		$first_name = &#8221;;<br />
	$first_name = apply_filters(&#8217;pre_user_first_name&#8217;, $first_name);</p>
<p>	if ( empty($last_name) )<br />
		$last_name = &#8221;;<br />
	$last_name = apply_filters(&#8217;pre_user_last_name&#8217;, $last_name);</p>
<p>	if ( empty($description) )<br />
		$description = &#8221;;<br />
	$description = apply_filters(&#8217;pre_user_description&#8217;, $description);</p>
<p>	if ( empty($rich_editing) )<br />
		$rich_editing = &#8216;true&#8217;;</p>
<p>	if ( empty($admin_color) )<br />
		$admin_color = &#8216;fresh&#8217;;<br />
	$admin_color = preg_replace(&#8217;|[^a-z0-9 _.\-@]|i&#8217;, &#8221;, $admin_color);</p>
<p>	if ( empty($user_registered) )<br />
		$user_registered = gmdate(&#8217;Y-m-d H:i:s&#8217;);</p>
<p>	$data = compact( &#8216;user_pass&#8217;, &#8216;user_email&#8217;, &#8216;user_url&#8217;, &#8216;user_nicename&#8217;, &#8216;display_name&#8217;, &#8216;user_registered&#8217; );<br />
	$data = stripslashes_deep( $data );</p>
<p>	if ( $update ) {<br />
		$wpdb-&gt;update( $wpdb-&gt;users, $data, compact( &#8216;ID&#8217; ) );<br />
		$user_id = (int) $ID;<br />
	} else {<br />
		$wpdb-&gt;insert( $wpdb-&gt;users, $data + compact( &#8216;user_login&#8217; ) );<br />
		$user_id = (int) $wpdb-&gt;insert_id;<br />
	}</p>
<p>	update_usermeta( $user_id, &#8216;first_name&#8217;, $first_name);<br />
	update_usermeta( $user_id, &#8216;last_name&#8217;, $last_name);<br />
	update_usermeta( $user_id, &#8216;nickname&#8217;, $nickname );<br />
	update_usermeta( $user_id, &#8216;description&#8217;, $description );<br />
	update_usermeta( $user_id, &#8216;jabber&#8217;, $jabber );<br />
	update_usermeta( $user_id, &#8216;aim&#8217;, $aim );<br />
	update_usermeta( $user_id, &#8216;yim&#8217;, $yim );<br />
	update_usermeta( $user_id, &#8216;rich_editing&#8217;, $rich_editing);<br />
	update_usermeta( $user_id, &#8216;admin_color&#8217;, $admin_color);</p>
<p>	if ( $update &amp;&amp; isset($role) ) {<br />
		$user = new WP_User($user_id);<br />
		$user-&gt;set_role($role);<br />
	}</p>
<p>	if ( !$update ) {<br />
		$user = new WP_User($user_id);<br />
		$user-&gt;set_role(get_option(&#8217;default_role&#8217;));<br />
	}</p>
<p>	wp_cache_delete($user_id, &#8216;users&#8217;);<br />
	wp_cache_delete($user_login, &#8216;userlogins&#8217;);</p>
<p>	if ( $update )<br />
		do_action(&#8217;profile_update&#8217;, $user_id);<br />
	else<br />
		do_action(&#8217;user_register&#8217;, $user_id);</p>
<p>	return $user_id;<br />
}</p>
<p>/**<br />
 * wp_update_user() - Update an user in the database<br />
 *<br />
 * It is possible to update a user&#8217;s password by specifying the<br />
 * &#8216;user_pass&#8217; value in the $userdata parameter array.<br />
 *<br />
 * If $userdata does not contain an &#8216;ID&#8217; key, then a new user<br />
 * will be created and the new user&#8217;s ID will be returned.<br />
 *<br />
 * If current user&#8217;s password is being updated, then the cookies<br />
 * will be cleared.<br />
 *<br />
 * @since 2.0.0<br />
 * @see wp_insert_user() For what fields can be set in $userdata<br />
 * @uses wp_insert_user() Used to update existing user or add new one if user doesn&#8217;t exist already<br />
 *<br />
 * @param array $userdata An array of user data.<br />
 * @return int The updated user&#8217;s ID.<br />
 */<br />
function wp_update_user($userdata) {<br />
	$ID = (int) $userdata['ID'];</p>
<p>	// First, get all of the original fields<br />
	$user = get_userdata($ID);</p>
<p>	// Escape data pulled from DB.<br />
	$user = add_magic_quotes(get_object_vars($user));</p>
<p>	// If password is changing, hash it now.<br />
	if ( ! empty($userdata['user_pass']) ) {<br />
		$plaintext_pass = $userdata['user_pass'];<br />
		$userdata['user_pass'] = wp_hash_password($userdata['user_pass']);<br />
	}</p>
<p>	// Merge old and new fields with new fields overwriting old ones.<br />
	$userdata = array_merge($user, $userdata);<br />
	$user_id = wp_insert_user($userdata);</p>
<p>	// Update the cookies if the password changed.<br />
	$current_user = wp_get_current_user();<br />
	if ( $current_user-&gt;id == $ID ) {<br />
		if ( isset($plaintext_pass) ) {<br />
			wp_clear_auth_cookie();<br />
			wp_set_auth_cookie($ID);<br />
		}<br />
	}</p>
<p>	return $user_id;<br />
}</p>
<p>/**<br />
 * wp_create_user() - A simpler way of inserting an user into the database.<br />
 *<br />
 * Creates a new user with just the username, password, and email. For a more<br />
 * detail creation of a user, use wp_insert_user() to specify more infomation.<br />
 *<br />
 * @since 2.0.0<br />
 * @see wp_insert_user() More complete way to create a new user<br />
 * @uses $wpdb Escapes $username and $email parameters<br />
 *<br />
 * @param string $username The user&#8217;s username.<br />
 * @param string $password The user&#8217;s password.<br />
 * @param string $email The user&#8217;s email (optional).<br />
 * @return int The new user&#8217;s ID.<br />
 */<br />
function wp_create_user($username, $password, $email = &#8221;) {<br />
	global $wpdb;</p>
<p>	$user_login = $wpdb-&gt;escape($username);<br />
	$user_email = $wpdb-&gt;escape($email);<br />
	$user_pass = $password;</p>
<p>	$userdata = compact(&#8217;user_login&#8217;, &#8216;user_email&#8217;, &#8216;user_pass&#8217;);<br />
	return wp_insert_user($userdata);<br />
}</p>
<p>?&gt;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
