This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Bruno Kos 3 months, 2 weeks ago.

Assigned support staff: Bruno Kos.

Author Posts
July 1, 2019 at 1:24 pm #4119373

andresP-5

Hi Support,

I am trying to create the post and my post is successfully created but I your plugin is causing issue to return the Post ID and we getting Fatal error as mentioned in the title.

I opened to following the fatel error and commented the following code:

wp-content/plugins/wpml-translation-management/inc/actions/wpml-tm-post-actions.class.php

/**
* @param int $post_id
*
*/
public function save_translation_priority( $post_id ) {

// $translation_priority = filter_var(
// ( isset( $_POST['icl_translation_priority'] ) ? $_POST['icl_translation_priority'] : '' ),
// FILTER_SANITIZE_FULL_SPECIAL_CHARS );

// if( !$translation_priority ){
// $assigned_priority = wp_get_object_terms( $post_id, 'translation_priority' );

// if( $assigned_priority ){
// $translation_priority = $assigned_priority[0]->term_id;
// }
// }

// wp_set_post_terms( $post_id, array( (int) $translation_priority ), 'translation_priority' );
}

After comments, everything works perfectly, Could you please let me know what is the issue and how we can resolved.

Here is my code to create a post:

$post_id = wp_insert_post(array (
'post_type' => 'post',
'post_title' => $_POST['post_title'],
'post_content' => $_POST['post_content'],
'post_status' => 'publish', //publish
'comment_status' => 'closed',
'ping_status' => 'closed',
));

Please let me know if I am doing wrong.

July 1, 2019 at 2:55 pm #4120469

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Thank you for contacting WPML support!

If you don't mind, I will need some more info on how this works in your website. When you say:

I am trying to create the post

How exactly are you creating posts? Are you using regular WordPress posting capabilities or some sort of a form?

I guess that the error occurs upon this form submission, but only if WPML is active and/or the above code is not commented out?

Also, can you provide debug information so I could get a better view of your current setup? I have enabled debug information for this ticket and this is how you can easily provide this info:
https://wpml.org/faq/provide-debug-information-faster-support/

Regards,
Bruno Kos

The topic ‘[Closed] Fatal error: Uncaught Error: Cannot use object of type WP_Error as array WPML’ is closed to new replies.