lundi 5 octobre 2015

wp_insert_post not working anymore in new version?

On a site we're developing we allow registered users to submit content via Wordpress search if it doesn't already exist. If content is found it goes to the post.

If no content is found it submits the content via wp_insert_post. It then refreshes and finds the post.

After updating Wordpress and deactivating debug (we're almost ready to go live) the content submission isn't working.

$current_user = wp_get_current_user();  
$author_ID = $current_user->ID;
$title = get_search_query();

if( null == get_page_by_title( $title ) ) {

wp_insert_post(
        array(
            'comment_status'    =>  'default_comment_status',
            'ping_status'       =>  'default_ping_status',
            'post_author'       =>  $author_ID,
            'post_title'        =>  $title,
            'post_status'       =>  'publish',
            'post_type'     =>  'my',
            'comment_status'        =>      'open'
        )
    );

echo '<META HTTP-EQUIV="REFRESH" CONTENT="1">' ; 

Has something changed in the new versions?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire