Skip Navigation

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.

This topic contains 14 replies, has 2 voices.

Last updated by Noman 7 months ago.

Assisted by: Noman.

Author Posts
February 14, 2024 at 1:20 pm #15302541

pabloD-14

Hey,

Since one of your latest updates, our users stopped being able to translate pages. Now we need to assign them as translators and configure their language pairs for them to be able to translate. We cannot afford this.

Reading into your code we see now you are using the function is_translator_filter directly, so we cannot filter it through wordpress core filter functionality, and there is not capability or role to let a user translate everypage independent from language.

We need our users of a given role to be able to translate every page without manual configuration into the wpml panel. Do you have any functionality for this? Planning on implemet some?

Looking into your older tickets and support you suggest to use your is_translator_filter filter, but since the last updates, now you are calling the function directly and we cannot hook into it properly to bypass the language pairs properly.

Thanks!

February 19, 2024 at 8:05 am #15316250

pabloD-14

Hey,
The issue is now replicated in teh sandbox you gave me. An user with a custom role being able to edit translations with no language pairs.
If you upgrade the plugin to last version it will stop working.
Thanks.

February 19, 2024 at 4:32 pm #15319592

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for replicating the issue on fresh WP site. It appears the problem occurs when updating the WPML Multilingual CMS plugin from version 4.6.6 to 4.6.7

Could you please confirm the steps you followed to replicate the issue:

1. Added custom code in the functions.php file from line #660 to 776

2. Created a user with the custom role “Mirai Front”

3. Logged in as that user and translated a page without adding them as a translator.

Please let me know if I missed any step.

Thank you

February 20, 2024 at 9:45 am #15321427

pabloD-14

Yes, I think that's all. Thx

February 21, 2024 at 9:55 am #15326497

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for confirmation, I am trying couple of workarounds to see if we can make it work with the current code. I need bit more time to try it out, I will update you today with my findings, if the fix does not work then I will escalate it.

Thank you for your cooperation and patience.

February 21, 2024 at 7:03 pm #15330073

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Could you please try to follow the suggestions from this thread (Summary at top of the page): https://wpml.org/forums/topic/issue-with-wpml-admin-capabilities/#post-15220070 and see if this resolves your issue?

I’ve tested at our fresh WP site and it seems to be working correctly for me. Could you please check and confirm?

Thank you

February 21, 2024 at 7:45 pm #15330291

pabloD-14

Hi, it is what I can see in the link you sent me...
Please send me the right one.
Thanks.

Screenshot_3.png
February 22, 2024 at 6:39 am #15331115

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Sorry for having issues accessing that ticket. The steps are as follows:

1. Edit the file /wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/wp/classes/User.php

2. Replace the following code (line 222):

return self::hasCap( self::CAP_ADMINISTRATOR, $user ); 

With:

return self::hasCap('manage_options', $user);

And see if this resolves your issue.

Thank you

February 22, 2024 at 7:18 am #15331224

pabloD-14

Hi Noman, yes it works, but I have a question, it is a issue that you have or it is a fix just for me, because I don´t want to hack your plugin code and I will have to put this code every time when I update your plugin.

Thanks.

February 22, 2024 at 7:00 pm #15335400

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Yes that makes sense. I have escalated this issue to our 2nd tier support team for further review and I will keep you updated as soon as I receive feedback from their end.

Thank you

February 26, 2024 at 10:53 am #15343585

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Our 2nd tier said, that change was required and now, users can't add or edit translations unless they are set up as translators and have their language pairs configured correctly: https://wpml.org/documentation/translating-your-contents/how-to-set-up-local-translators-and-language-pairs/

So, either use the workaround that we shared in the previous reply or update your code and assign the language pairs to the users programmatically (e.g. the user can translate from EN to ES or FR)

You may review the below file, how we manage the language pairs and update your code accordingly: wp-content\plugins\sitepress-multilingual-cms\classes\language\class-wpml-language-pair-records.php

If you need help with custom code, I would suggest you consider contacting one of our certified partners from this link: http://wpml.org/documentation/support/wpml-contractors/ You will get the custom assistance you need to get on with your project.

Please let me know if you have any questions.

Thank you

February 26, 2024 at 12:46 pm #15344377

pabloD-14

Hi Nomad, thanks for your reply.
I don´t have any custom code, I have lot sites using your plugin and after updale your last version the editors can´t translate, and it is a problem because I can not give to all editors a administrator rol, and also the problem is that I have a lot sites using your plugin and put language pairs to all users in all sites is a crazy and massive task.

February 27, 2024 at 12:32 pm #15349053

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I want to clarify that the default behavior of WPML requires users to be set up as translators in WPML >> Translation Management >> Translators with correct language pairs. Your site is using below custom code in the theme's functions.php file to modify WPML's default behavior:

function set_editor_permissions() {
   $editor = get_role('editor');

$editor-\>add_cap('wpml_manage_translation_management');
$editor-\>add_cap('wpml_manage_translation_options');
$editor-\>add_cap('wpml_manage_wp_menus_sync');
$editor-\>add_cap('manage_wpml_packages');
$editor-\>add_cap('wpml_manage_languages');
$editor-\>add_cap('wpml_manage_taxonomy_translation');
$editor-\>add_cap('wpml_manage_wp_menus_sync');
$editor-\>add_cap('wpml_manage_navigation');

}
add_action('admin_init', 'set_editor_permissions');

function remove_wmpl_rest_url_filter() {

mi_remove_filter('rest_url', 'convertRestUrl');


}
add_action( 'admin_init', 'remove_wmpl_rest_url_filter' );

function mi_remove_filter($tag, $function_name, $priority = 10){


global $wp_filter;

if( isset($wp_filter[$tag]->callbacks[$priority]) and !empty($wp_filter[$tag]->callbacks[$priority]) ){

	$wp_filter[$tag]->callbacks[$priority] = array_filter($wp_filter[$tag]->callbacks[$priority], function($v, $k) use ($function_name){

		return ( stripos($k, $function_name) === false );

	}, ARRAY_FILTER_USE_BOTH );
}


}

remove_role('mirai_front');
add_role(
'mirai_front',
__( 'Mirai Front' ),
array(
//Basics
'read' =\> true, // Show admin dashboard

		//Sites
		'manage_network' => true, // Allow the access to the network dashboard
		'manage_sites' => true, // Give access to 'sites' tab of the network dashboard
		'mi_see_settings' => true, // Custom capability: been able to see options tab

		//Posts
		'create_posts' => true, // Crear un post
		'edit_others_posts' => true, // Editar un post
		'edit_posts' => true, // Editar un post
		'edit_private_posts' => true, // Editar un post
		'read_private_posts' => true, //Editar un post
		'edit_published_posts' => true, // Editar un post
		'publish_posts' => true, //Publicar un post
		'delete_others_posts' => true, //Eliminar un post
		'delete_posts' => true, //Eliminar un post
		'delete_published_posts' => true, //Eliminar un post
		'delete_private_posts' => true, //Eliminar un post privado

		//Páginas
		'edit_pages' => true, //Crear una página
		'create_pages' => true,  //Crear una página
		'publish_pages' => true, //Crear una página
		'edit_private_pages' => true, //Editar una página
		'read_private_pages' => true, //Editar una página
		'edit_published_pages' => true, //Editar una página
		'edit_others_pages' => true, //Editar una página
		'delete_others_pages' => true, //Eliminar páginas
		'delete_pages' => true, //Eliminar páginas
		'delete_private_pages' => true, //Eliminar páginas
		'delete_published_pages' => true, //Eliminar páginas
		
		//Elementor
		'manage_elementor_templates' => true, // Access to elementor templates
		'manage_options' => true, // Needed to see elementor and essential addons tab. See custom filters on bottom.	
		'manage_network_themes' => true, // Access to network theme editor so the role can edit css of current theme
		'mi_manage_elementor' => true, // Custom capability: Access to elementor admin pages

		//WPML
		'wpml_manage_translation_management' => true, //Agregar / Editar traducciones
		'wpml_manage_translation_options' => true, // Agregar / Editar traducciones
		'wpml_manage_wp_menus_sync' => true, //Sincronizacion de menus wpml
		'manage_wpml_packages' => true, // Ver el menu de WPML
		'wpml_manage_languages' => true, // Cambiar idiomas
		'wpml_manage_taxonomy_translation' => true,
		'wpml_manage_wp_menus_sync' => true,
		'wpml_manage_navigation' => true,

		//MISC
		'mi_invalidate_cloudfront' => true, //Custom, Cloudfront cache invalidation but no settings
		'manage_contact_db' => true, //See contactdb 
		'upload_files' => true, //Subir imagenes a media
		'wpseo_manage_options' => true, //Modificar opciones de Yoast
		'unfiltered_html' => true, //Meter iframes
		'manage_categories' => true, //Crear nuevas categorias
		'mi_manage_redirection' => true, // Custom mirai capability for accessing Tool Menu redirections			
		'edit_theme_options' => true, // Access to theme options different than edition css. Most of them are custom disabled by mi_manage_themes
		'mi_mirai_options' => true, //Access to Mirai Options page	
		'edit_themes' => true, //Access to the css editing
		'mi_manage_redirections' => true, //Manage redirections
		'gdpr' => true,	//Custom: Show the GDPR panel
		'moderate_comments' => true, // Show the comments panel
		
		//JOB MANAGER
		'manage_job_listings' => true,
		'edit_job_listings' => true,
		'publish_job_listings' => true,		
		'edit_others_job_listings' => true,
		'manage_job_applications' => true,
		'edit_job_applications' => true,
		'publish_job_applications' => true,
		'edit_others_job_applications' => true,		
	)
);

This code grants necessary capabilities to the "mirai_front" role. However, with the recent changes, users must have language pairs configured to edit translations.

To resolve this issue:

1. Update your code to assign correct language pairs programmatically. This ensures users can continue translating without manual setup.

2. I understand this may be difficult for you. I've included your case in our existing feature request to expedite its resolution. Please note, the feature request is currently under discussion, and we can't provide an ETA.

Feel free to reach out if you have any questions.

Thank you

February 27, 2024 at 2:32 pm #15349588

pabloD-14

ok, I will wait your reply, thanks

February 28, 2024 at 5:39 pm #15355361

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Feature request added to change behavior.

Please note as a supporter I tried everything in my power to report it, rest is on our development teams to look after these requests. I have followed our workflows to report it.

Thanks

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.