Skip navigation

Resolved

Resolved in: WPML 4.7.6

Topic Tags: Compatibility

Overview of the issue

With Elementor Pro widget advanced settings can add Display Conditions, e.g. to only show a widget if the user is logged in.

Recently something changed with how Elementor stores this data, and it can trigger the following error:

PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in .../wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/Hooks/DisplayConditions.php:138

Workaround

We will update our code to handle this change in Elementor data storage. In the meantime you can edit this plugin file: wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/Hooks/DisplayConditions.php

Locate the function convertConditionIds (from line 134 in the current version), and replace it with the code below:

	private function convertConditionIds( array $conditionGroups ) {

		// ensure $conditionGroups is an array of arrays and not just an associative array
		$result = array_keys($conditionGroups)[0] !== 0 ? array($conditionGroups) : $conditionGroups;

		foreach ( $result as $key => $conditionGroup ) {
			$configForCondition = $this->getConfigForCondition( $conditionGroup['condition'] );

			if ( $configForCondition && isset( $conditionGroup[ $configForCondition['field'] ] ) ) {
				$result[ $key ] = $this->convertIdsForCondition( $conditionGroup, $configForCondition );
			}
		}

		return $result;
	}