Pubblicazione già approvata da $apprveto2ins[1] !

'; echo $html; echo ""; echo ""; exit(); } else { if ( $apprveto2ins[2] == '1'){ $html = '

Pubblicazione già sottoposta a veto da $apprveto2ins[3] !

'; echo $html; echo ""; echo ""; exit(); } } $query = "UPDATE wp_articoli SET appr = 1, wp_articoli.emailAppr = '$email' WHERE wp_articoli.doi = '$doi'"; $res3 = mysqli_query($dbhandle,$query); $queryPost = "SELECT wp_articoli.authors,wp_articoli.published,wp_articoli.title,wp_articoli.ajournal,wp_articoli.doi,wp_articoli.summary FROM wp_articoli WHERE wp_articoli.doi = '$doi'"; $post2ins = mysqli_query($dbhandle,$queryPost); $post2insarr = mysqli_fetch_array($post2ins); $year = strtok($post2insarr[1], '-'); //echo $year; $year2ins = array($year); $post2 = array( 'post_author' => 1, 'post_content' => $post2insarr[5], 'post_title' => $post2insarr[2], 'post_name' => 'my-page', //'tax_input' => $year2ins[0], 'post_category' => $year2ins, 'tags_input' => array($post2insarr[0]), 'meta_input' => array( 'rivista' => $post2insarr[3], 'arxivdoi' => $post2insarr[4] ), 'post_excerpt' => '', 'post_status' => 'publish', 'comment_status' => 'close', 'ping_status' => 'open', 'post_type' => 'post', 'comment_count' => 0 ); $postid = wp_insert_post($post2); $query = " SELECT name FROM wp_terms"; //echo $query; $res4 = mysqli_query($dbhandle,$query); $rows = array(); while(($row = mysqli_fetch_array($res4))) { $rows[] = $row; } //$res4arr = mysqli_fetch_array($res4); if (in_array($year, $rows)) { $cat2ins = get_cat_ID( $year ); } else { wp_create_category( $year); $cat2ins = get_cat_ID( $year ); } //$test = array('8'); //wp_set_post_terms( $postid, $year2ins, 'category'); wp_set_post_categories( $postid, $cat2ins ); $html = '

Pubblicazione inserita correttamete !

'; echo $html; echo ""; //echo ""; mysqli_close($dbhandle); } else { $query = "SELECT appr,emailAppr,veto,emailVeto FROM wp_articoli WHERE wp_articoli.doi = '$doi'"; $apprveto = mysqli_query($dbhandle,$query); $apprveto2ins = mysqli_fetch_array($apprveto); if ( $apprveto2ins[2] == '1'){ $html = '

Pubblicazione già sottoposta a veto da $apprveto2ins[3] !

'; echo $html; echo ""; echo ""; exit(); } else { if ( $apprveto2ins[0] == '1'){ $html = '

Pubblicazione già approvata da $apprveto2ins[1] !

'; echo $html; echo ""; echo ""; exit(); } } $query = "UPDATE wp_articoli SET veto = 1, wp_articoli.emailVeto = '$email' WHERE wp_articoli.doi = '$doi'"; $res5 = mysqli_query($dbhandle,$query); $html = '

Pubblicazione sottooposta a veto correttamete !

'; echo $html; echo ""; } } else { //echo "App is empty"; ; } } add_action('init', 'insertpub'); ?>