Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client encountered a fatal error after setting up WPML on a multisite installation. The error was related to a call to a member function

add_cap()

on null within the WPML plugin's upgrade script.

Solution:
We recommended the following steps to resolve the issue:
1. Navigate to the file

wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/commands/AddTranslationManagerCapToAdmin.php

.
2. Open the file and locate the line:

get_role( 'administrator' )->add_cap( User::CAP_MANAGE_TRANSLATIONS );

3. Replace it with the following code to check if the administrator role exists before attempting to add capabilities:

if(get_role( 'administrator' )!= NULL){
    get_role( 'administrator' )->add_cap( User::CAP_MANAGE_TRANSLATIONS );
}

4. Save the changes.
We also advised the client to back up their database before making any changes.

Please note that this solution might be outdated or not applicable to your case. If the issue persists, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you need further assistance, please open a new support ticket.

0% of people find this useful.

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 12 replies, has 3 voices.

Last updated by Andrey 1 year, 2 months ago.

Assisted by: Andrey.

Author Posts
March 5, 2024 at 2:22 pm #15374966

fulviaL

I installed WPML in my multisite as I have done a lot of time.
I activate the plugin at multisite level,then I went in a subside to setup wpml and I did all at the end when I clicked on finsish this is the result. And I had to delete the plugins....

Fatal error: Uncaught Error: Call to a member function add_cap() on null in /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/commands/AddTranslationManagerCapToAdmin.php:10 Stack trace: #0 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/class-wpml-upgrade-run-all.php(11): WPML\Upgrade\Commands\AddTranslationManagerCapToAdmin->run() #1 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/class-wpml-upgrade.php(159): WPML_Upgrade_Run_All->run_admin() #2 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/class-wpml-upgrade.php(147): WPML_Upgrade->maybe_run_admin() #3 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/class-wpml-upgrade.php(131): WPML_Upgrade->run_command() #4 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/class-wpml-upgrade.php(116): WPML_Upgrade->run_commands() #5 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/class-wpml-upgrade.php(80): WPML_Upgrade->run_admin() #6 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/class-wpml-upgrade-loader.php(150): WPML_Upgrade->run() #7 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-includes/class-wp-hook.php(324): WPML_Upgrade_Loader->wpml_upgrade() #8 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #9 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-includes/plugin.php(517): WP_Hook->do_action() #10 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php(523): do_action() #11 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-includes/class-wp-hook.php(324): SitePress->init() #12 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #13 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-includes/plugin.php(517): WP_Hook->do_action() #14 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-settings.php(506): do_action() #15 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-config.php(110): require_once('...') #16 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-load.php(50): require_once('...') #17 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-admin/admin.php(34): require_once('...') #18 /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-admin/index.php(10): require_once('...') #19 {main} thrown in /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/commands/AddTranslationManagerCapToAdmin.php on line 10

Notice: La funzione is_embed è stata richiamata in maniera scorretta. I tag condizionali di una query non funzionano prima che la query sia stata eseguita. Prima dell'esecuzione restituiscono sempre il valore False. Leggi Debugging in WordPress per maggiori informazioni. (Questo messaggio è stato aggiunto nella versione 3.1.0.) in /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-includes/functions.php on line 6031

Notice: La funzione is_search è stata richiamata in maniera scorretta. I tag condizionali di una query non funzionano prima che la query sia stata eseguita. Prima dell'esecuzione restituiscono sempre il valore False. Leggi Debugging in WordPress per maggiori informazioni. (Questo messaggio è stato aggiunto nella versione 3.1.0.) in /var/www/vhosts/snsipro.com/httpdocs/mysnsi_stage/wp-includes/functions.php on line 6031

March 5, 2024 at 2:40 pm #15375063

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

Thanks for contacting us.

Before your ticket is assigned to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process.

Please make a backup of your site and try to delete the WPML plugins and reinstall them to see if it gets the issue fixed.

If the issue persist, can you please test minimal, using a default theme(if applicable) and with all non-WPML and essentials plugins disabled to see if the error persists.

Please let us know your results.
Mateus

March 7, 2024 at 8:42 am #15382720

fulviaL

I have done what you suggest 2 times with the same result.
It would be a shame if I am force to pass to polylang but I am afraid this willbe my road as I can't have this kind of issues...

March 7, 2024 at 11:22 am #15383896

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

This is Andrey here. I will be assisting you further.

Could you please also try to reset WPML completely and activate it again? You can do this by going to WPML → Support, clicking the Troubleshooting link, and selecting the I am about to reset all translation and language data checkbox.

https://wpml.org/documentation/getting-started-guide/language-setup/deleting-languages-and-plugin-data-by-doing-a-wpml-reset-on-your-site/#step-3-do-the-wpml-reset

I've enabled debug information for this support ticket. Please see this link for how to get this information from your site and give it to us:
http://wpml.org/faq/provide-debug-information-faster-support/

March 7, 2024 at 3:59 pm #15385659

fulviaL

hello,
maybe my englis is sobad that you do not understand my problem. When I install the plugin, wordpress is not accessible anymore in noway and all what I can see is what I copied and paste in my first tiket.
Now the plugin is uninstalled from my site, I should reinstall again but I have doen 3 times getting the same result.
Thanks and kind regards

March 7, 2024 at 4:22 pm #15385904

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

I need to request temporary access (wp-admin and FTP) to your site – preferably to a test site where the problem has been replicated if possible – in order to be of better help. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Please write the exact steps on how to replicate the problem.

March 11, 2024 at 3:06 pm #15396210

fulviaL

consider also that all oother websites are in the same server, we use AWS since many many years and never face a problem like that.

March 12, 2024 at 9:13 am #15398168

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Thank you. I will update you as soon as I know more.

March 12, 2024 at 4:27 pm #15400711

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Could you please try the following workaround?

– Go to file wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/commands/AddTranslationManagerCapToAdmin.php

– Open it

– Find the line

get_role( 'administrator' )->add_cap( User::CAP_MANAGE_TRANSLATIONS );

– Change to

		if(get_role( 'administrator' )!= NULL){
			get_role( 'administrator' )->add_cap( User::CAP_MANAGE_TRANSLATIONS );
		}

– Save it

Please backup your database before making any changes.

March 13, 2024 at 7:43 am #15402233

fulviaL

I will tell you what you have done! you changed the url where we are sent when any user login destroying our job. What I am going to do I am goimg to delete your pluign forever and our dev is already doing a very simple customization to export exel file, translate and import.
I will never use again this plugin that never works as supposed too.

March 13, 2024 at 8:25 am #15402340

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

I apologize for any confusion, but I did not apply any changes to your staging site. I was only deactivating and reactivating the plugins. If a plugin was not activated, it could result in missing functionality that may appear as if changes have been made.

March 13, 2024 at 9:48 am #15402816

fulviaL

it is clear that you even do not know what you are doing. as soon as I deleted the plugin everything is back perfect. No need of assistance anymore. I will not use anymore your plugin in the new sites we developed.
Thanks for your assistance.

March 13, 2024 at 9:53 am #15402866

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

Would you mind me to check an issue you're experiencing? Can you please provide me with a detailed explanation?