Ver Mensaje Individual
  #16 (permalink)  
Antiguo 24/01/2012, 03:41
Fernando_net
 
Fecha de Ingreso: marzo-2010
Mensajes: 191
Antigüedad: 14 años, 1 mes
Puntos: 3
Respuesta: Registro con campos personalizados + Base de datos - No se guardan los dat

He cambiado la función de registro, aplicando las nuevas variables que las capture del constructor. He hecho un print (ahora no aparece) para ver si capta las variables y si, en efecto, la página capta las variables, pero la Base de datos no las recoge...

Pego la función a ver si se ve algo anomalo:

Código PHP:
Ver original
  1. function register_new_user( $user_login, $user_email, $user_centro, $user_especialidad, $user_participantes, $user_telefono ) {
  2.     $errors = new WP_Error();
  3.  
  4.     $sanitized_user_login = sanitize_user( $user_login );
  5.     $user_email = apply_filters( 'user_registration_email', $user_email );
  6.     $user_centro = $user_centro;
  7.     $user_especialidad = $user_especialidad;
  8.     $user_participantes = $user_participantes;
  9.     $user_telefono = $user_telefono;
  10.  
  11.     // Check the username
  12.     if ( $sanitized_user_login == '' ) {
  13.         $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Please enter a username.' ) );
  14.     } elseif ( ! validate_username( $user_login ) ) {
  15.         $errors->add( 'invalid_username', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ) );
  16.         $sanitized_user_login = '';
  17.     } elseif ( username_exists( $sanitized_user_login ) ) {
  18.         $errors->add( 'username_exists', __( '<strong>ERROR</strong>: This username is already registered, please choose another one.' ) );
  19.     }
  20.  
  21.     // Check the e-mail address
  22.     if ( $user_email == '' ) {
  23.         $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please type your e-mail address.' ) );
  24.     } elseif ( ! is_email( $user_email ) ) {
  25.         $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The email address isn’t correct.' ) );
  26.         $user_email = '';
  27.     } elseif ( email_exists( $user_email ) ) {
  28.         $errors->add( 'email_exists', __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ) );
  29.     }
  30.  
  31.     do_action( 'register_post', $sanitized_user_login, $user_email, $errors );
  32.  
  33.     $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );
  34.  
  35.     if ( $errors->get_error_code() )
  36.         return $errors;
  37.  
  38.     $user_pass = wp_generate_password( 12, false);
  39.     $user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email, $user_centro, $user_especialidad, $user_participantes, $user_telefono);
  40.     if ( ! $user_id ) {
  41.         $errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ) );
  42.         return $errors;
  43.     }
  44.  
  45.     update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag.
  46.  
  47.     wp_new_user_notification( $user_id, $user_pass, $user_mail, $user_centro, $user_especialidad, $user_participantes, $user_telefono );
  48.  
  49.     return $user_id;
  50. }

Muchas gracias por la ayuda...