Skip Navigation

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

Problem:

I get an error Fatal error: Uncaught Error: Call to a member function add_cap() on null

Solution:

Usually, it means roles/ capabilities of your website roles were messed up or adjusted by some 3rd party plugin that caused the issues.

- Add the code below to the functions.php file of your theme to reset the roles

if ( !function_exists( 'populate_roles' ) ) {
  require_once( ABSPATH . 'wp-admin/includes/schema.php' );
}
  
populate_roles();

Source:
- https://wordpress-219772-2339659.cloudwaysapps.com/wp-admin/
- https://wpml.org/forums/topic/activation-causes-fatal-error/page/3/#post-10254559

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 4 replies, has 2 voices.

Last updated by Igor Ilgiyaev 1 year, 10 months ago.

Assisted by: Dražen Duvnjak.

Author Posts
January 26, 2022 at 12:40 pm #10435629

Igor Ilgiyaev

Fatal error: Uncaught Error: Call to a member function add_cap() on null in /home/606382.cloudwaysapps.com/banywgbnnq/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/commands/AddTranslationManagerCapToAdmin.php:10 Stack trace: #0 /home/606382.cloudwaysapps.com/banywgbnnq/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/class-wpml-upgrade-run-all.php(11): WPML\Upgrade\Commands\AddTranslationManagerCapToAdmin->run() #1 /home/606382.cloudwaysapps.com/banywgbnnq/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/class-wpml-upgrade.php(159): WPML_Upgrade_Run_All->run_admin() #2 /home/606382.cloudwaysapps.com/banywgbnnq/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/class-wpml-upgrade.php(147): WPML_Upgrade->maybe_run_admin(Object(WPML\Upgrade\Commands\AddTranslationManagerCapToAdmin)) #3 /home/606382.cloudwaysapps.com/banywgbnnq/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/class-wpml-upgrade.php(131 in /home/606382.cloudwaysapps.com/banywgbnnq/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/upgrade/commands/AddTranslationManagerCapToAdmin.php on line 10

Notice: is_embed was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /home/606382.cloudwaysapps.com/banywgbnnq/public_html/wp-includes/functions.php on line 5663

Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /home/606382.cloudwaysapps.com/banywgbnnq/public_html/wp-includes/functions.php on line 5663

January 28, 2022 at 6:57 am #10452285

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

thanks for contacting us.

This is a known issue, it is an issue with the user roles on your website.

Let me explain:

WPML tries to make all the admin users the translation manager. The error happens as WPML detects there is NO admin user.

Well, it is not possible to have no admin user that is why the issue is that the roles of the users of your website are messed up.

The initial suspect was there is a plugin in question that gives some sort of possibility to change the roles.

The fix would be recommended below to reset the roles:

- Add the code below to the functions.php file of your theme:

if ( !function_exists( 'populate_roles' ) ) {
  require_once( ABSPATH . 'wp-admin/includes/schema.php' );
}
 
populate_roles();

Source:
- hidden link
- https://wpml.org/forums/topic/activation-causes-fatal-error/page/3/#post-10254559

Kind regards,
Drazen

January 29, 2022 at 9:11 am #10461301

Igor Ilgiyaev

NO Admins???
That's weird
It is a multisite so maybe this is the issue that it is not showing admin but super admins?

January 31, 2022 at 6:49 am #10466897

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

as said this is not possible to not have admin, so usually it means roles/ capatibilitis of your website roles were messed up or adjusted by some 3rd party plugin that caused the issues.

Please try the suggested fix from my last reply, and let me know how it goes.

Thanks,
Drazen

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