WordPress.org

Ready to get started?Download WordPress

Forums

wp_insert_post error, in_array wrong datatype for 2nd argument (4 posts)

  1. remus
    Member
    Posted 4 years ago #

    Hello,

    This isn't the first time I'm using wp_insert_post in plugins but this time I can't make it work for the soul of me!

    The post is successfully inserted but once I'm trying to view or edit it I get these errors:

    Warning: in_array() [function.in-array]: Wrong datatype for second argument in /path/wp-includes/post.php  on line 1997
    
    Warning: constant() [function.constant]: Couldn't find constant WP_POST_REVISIONS in /path/wp-includes/post.php on line 3714
    
    You can’t edit this post because it is in the Trash. Please restore it and try again.

    Any help wold be deeply and sincerely appreciated.

    Thanks.

  2. tslice
    Member
    Posted 4 years ago #

    I'm also getting this error, the in_array error in post.php line 1997

  3. tslice
    Member
    Posted 4 years ago #

  4. remus
    Member
    Posted 4 years ago #

    I validated the request with wp_nonce / check_admin_referer then run the submission function through the 'get_header' filter.

    e.g.

    add_action('get_header', 'add_new_post');

    I am not really sure how right this is but the problem has been fixed ...

Topic Closed

This topic has been closed to new replies.

About this Topic