Skip Navigation

Open

Topic Tags: Bug

Overview of the issue

In the Translators tab of the the page at WPML > Translation Management there is an option to add a Translation Manager which brings up a search box. In some scenarios searching for valid users does not return any users to be able to select.

That occurs when there are multiple roles with the minimum required permission, as would happen on a WooCommerce site, for example, where both the Shop Manager and core Editor roles have the required permission.

Workaround

There is no simple workaround that does not involve editing a WPML plugin file.

You can edit the file plugins/sitepress-multilingual-cms/classes/user/class-wpml-translation-roles-records.php.

Locate this line (around line 144):

$preparedUserQuery .= $this->wpdb->prepare( " AND c.meta_value LIKE %s", "%{$required_wp_role}%" );

and change the AND to OR like so:

$preparedUserQuery .= $this->wpdb->prepare( " OR c.meta_value LIKE %s", "%{$required_wp_role}%" );

Then locate this line (about line 168):

$users      = $this->wpdb->get_col( $preparedUserQuery );

and then append a second line immediately afterwards, like so:

$users      = $this->wpdb->get_col( $preparedUserQuery );
$users = array_unique( $users );

As always when making any such changes be sure to have a current backup before proceeding.

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>