Cannot use object of type WP_Error as array

Using a WordPress Plugin WPML I have been getting this error on saving a draft post: PHP Fatal error: Cannot use object of type WP_Error as array in /home/user/domain.com/wp-content/plugins/sitepress-multilingual-cms/inc/taxonomy-term-translation/wpml-term-translations.class.php on line 1018 On that line I have $new_term = wp_insert_term( $term_name, $taxonomy, array( ‘slug’ => self::term_unique_slug( sanitize_title( $term_name ), $taxonomy, $post_lang ) ) ); if … Read more

How to group multiple wp_errors together?

I have created a custom registration form on wordpress. There is validation errors for each field and wordpresss just dumps all errors above the form. I tried to separate these errors into multiple output each will appear below its input field in the form by calling get_error_message(‘error_code’); but, there is multiple errors for each field. … Read more

Why when I instantiate wp_error in a validation method my user registration method stops working?

I would really, really, appreciate any insight I can get here. I’m working on a WordPress plugin that registers users in WordPress and want to validate data submitted through the form. I have a class for this, here’s a condensed version of it: namespace PluginName\Includes\Forms\Classes; class Validation { public function validate_fields($field, $form_type){ $errors = new … Read more

How to display error messages using WP_Error class?

I have registration form code in my functions.php file like this if (‘POST’ == $_SERVER[‘REQUEST_METHOD’] && !empty($_POST[‘action’]) && $_POST[‘action’] == ‘registration’) { $error = new WP_Error(); if (empty(esc_attr($_POST[’email’]))) { $error->add(‘regerror’,’Email is required.’); } if (!is_email(esc_attr($_POST[’email’]))) { $error->add(‘regerror’,’Invalid email format.’); } if (email_exists(esc_attr($_POST[’email’]))) { $error->add(‘regerror’,’Email already in use. Did you forget your Password? If yes click … Read more

Error timed out with succesfull wp_remote_post

What I’m trying to do: Passing POST data by using wp_remote_post. foreach ( $articles as $article_id ) { $postarray = array( ‘method’ => ‘POST’, ‘timeout’ => 5, ‘redirection’ => 5, ‘httpversion’ => ‘1.0’, ‘blocking’ => true, ‘headers’ => array(), ‘body’ => array( ‘article_id’ => $article_id ), ‘cookies’ => array() ); $response = wp_remote_post($url, $postarray); if … Read more

Issue with wp_insert_post and post_content field error Could not update post in the database

I’m having issues creating an import / caching script to be used within a WordPress site. This feed comes from a single text file that is then parsed and returned as an array. When running through each item from the feed I am using the wp_insert_post function to add in the data (see below): $post … Read more

get_term_children for immediate children only (not grandchildren)

I want to display term children of a custom taxonomy. Currently, I am able to do this using get_term_children, but using this, it displays children and grandchildren, I want to avoid this and make that only immediate children are shown. This is what I have right now ( but it outputs children and grandchildren) : … Read more