• Resolved RosaKick

    (@rosakick)


    I’m making a modified version of a plugin called Event RSVP.
    The original plugin works fine, but my version returns the following error:

    WP_Error Object
    (
        [errors] => Array
            (
                [db_insert_error] => Array
                    (
                        [0] => Could not insert post into the database
                    )
    
            )
    
        [error_data] => Array
            (
            )
    
    )

    The code I’m using is:

    $post = array(
    	    'post_title'     => 'skidaskoli-registration-' . sha1( $name ), //Create unique title. is it necessary ?
    	    'post_status'    => 'publish',
    	    'post_type'      => 'skidaskoli-registration',
    	    'post_parent'    => $event_id,
    	    'post_date'      => date( 'Y-m-d H:i:s', time() )
    	);
    	$post_id = wp_insert_post( $post, true );

    code from original plugin is:

    $post = array(
    	    'post_title'     => 'ersvp-registration-' . sha1( $name ), //Create unique title. is it necessary ?
    	    'post_status'    => 'publish',
    	    'post_type'      => 'ersvp-registration',
    	    'post_parent'    => $event_id,
    	    'post_date'      => date( 'Y-m-d H:i:s', time() )
    	);
    	$post_id = wp_insert_post( $post );

Viewing 1 replies (of 1 total)
  • Thread Starter RosaKick

    (@rosakick)

    figured it out, turns out the post type wasn’t being created as the name was too long

Viewing 1 replies (of 1 total)
  • The topic ‘db_insert_error on wp_insert_post’ is closed to new replies.