Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » WordPress »

Insertar Post y post meta desde formulario

Estas en el tema de Insertar Post y post meta desde formulario en el foro de WordPress en Foros del Web. Arme este script, sin embargo tengo problemas cuando declaro: include_once ("../../../../wp-config.php"); include_once ("../../../../wp-load.php"); include_once ("../../../../wp-includes/wp-db.php"); ERROR: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código PHP: Ver original Deprecated : Function ...
  #1 (permalink)  
Antiguo 23/11/2011, 10:08
 
Fecha de Ingreso: abril-2009
Mensajes: 46
Antigüedad: 15 años
Puntos: 1
Insertar Post y post meta desde formulario

Arme este script, sin embargo tengo problemas cuando declaro:

include_once ("../../../../wp-config.php");
include_once ("../../../../wp-load.php");
include_once ("../../../../wp-includes/wp-db.php");

ERROR:
Código PHP:
Ver original
  1. Deprecated: Function set_magic_quotes_runtime() is deprecated in /var/www/tuseguridad/wp-settings.php on line 32 Warning: array_filter() expects parameter 1 to be array, integer given in /var/www/tuseguridad/wp-includes/post.php on line 2464


Código PHP:
Ver original
  1. <pre>
  2. <?php print_r($_POST['sos']);
  3.  
  4. function array_empty($mixed) {
  5.     if (is_array($mixed)) {
  6.         foreach ($mixed as $value) {
  7.             if (!array_empty($value)) {
  8.                 return false;
  9.             }
  10.         }
  11.     }
  12.     elseif (!empty($mixed)) {
  13.         return false;
  14.     }
  15.     return true;
  16. }
  17.  
  18. ?>
  19. </pre>
  20. <?php
  21.  
  22.     if (isset($_POST['submit'])) {     
  23.         if (!array_empty($_POST['sos']['data'])) {
  24.            
  25.             // DECLARO VARIABLES
  26.             $problema = $_POST['sos']['data'][0];
  27.             $descripcion = $_POST['sos']['data'][1];
  28.             $fecha = $_POST['sos']['data'][2];
  29.             $hora = $_POST['sos']['data'][3] . ":" . $_POST['sos']['data'][4] . " " . $_POST['sos']['data'][5];
  30.             //$min = $_POST['sos']['data'][4];
  31.             //$time = $_POST['sos']['data'][5];
  32.             $lugar = $_POST['sos']['data'][6];
  33.             $nombre = $_POST['sos']['data'][7];
  34.             $correo = $_POST['sos']['data'][8];
  35.            
  36.             include_once ("../../../../wp-config.php");
  37.             include_once ("../../../../wp-load.php");
  38.             include_once ("../../../../wp-includes/wp-db.php");
  39.            
  40.                 $post = array(
  41.                   'menu_order' => 0,
  42.                   'comment_status' => 'open',
  43.                   'ping_status' => get_option('default_ping_status'),
  44.                   'pinged' => '',
  45.                   'post_author' => 1,
  46.                   'post_category' => 7,
  47.                   'post_content' => $descripcion,
  48.                   'post_date' => $hora,
  49.                   'post_date_gmt' => '',
  50.                   'post_excerpt' => '',
  51.                   'post_name' => '',
  52.                   'post_parent' => 0,
  53.                   'post_password' => '',
  54.                   'post_status' => 'publish',
  55.                   'post_title' => $problema,
  56.                   'post_type' => 'post',
  57.                   'tags_input' => '',
  58.                   'to_ping' => '',
  59.                   'tax_input' => '',
  60.                 );  
  61.            
  62.             $the_post_id = wp_insert_post($post);
  63.            
  64.             if ($the_post_id) {
  65.                 update_post_meta( $the_post_id, 'autor_sos', $nombre );
  66.                 update_post_meta( $the_post_id, 'fecha_sos', $fecha );
  67.                 update_post_meta( $the_post_id, 'hora_sos', $hora );
  68.                 update_post_meta( $the_post_id, 'lugar_sos', $lugar );
  69.                 update_post_meta( $the_post_id, 'mail_sos', $correo );
  70.             }
  71.            
  72.            
  73.         } else { echo "Vacío"; } //Complete todos los campos
  74.     } else { echo "Ausente";  } //Muestro el Formulario y complete campos
  75.    
  76. ?>

APARENTEMENTE YA LO HE SOLUCINADO.
Aquí el error:
'post_category' => 7, deberia ir 'post_category' => array(7,),

Cualquier cosa comento.

Última edición por opzina2; 23/11/2011 a las 10:26
  #2 (permalink)  
Antiguo 23/11/2011, 10:33
Avatar de Nekko
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Buenos Aires
Mensajes: 3.141
Antigüedad: 16 años, 1 mes
Puntos: 656
Respuesta: Insertar Post y post meta desde formulario

Alguna posibilidad de que tu WordPress esté desactualizado?
http://ar.php.net/set_magic_quotes_runtime
__________________
Taller para crear themes wordpress desde cero | Presupuestos para trabajos particulares vía MP

Etiquetas: formulario, meta, php, post
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:24.