If the site has active users as administrators but the role has been edited in the database or removed, something like this might solve or at least help understand the problem.
No functions.php
:
add_action( 'init', function() {
// Imprime os roles existentes, pra conferir os role que já existem
var_dump( wp_roles() );
// Imprime o objeto WP_Role se foi criado, null se já existia
var_dump( add_role( 'administrator', 'Administrator' ) );
} );
From here you can recreate the capabilities:
// Reseta as capabilities básicas do WP
// CUIDADO: se o seu código tiver retirado capabilities de algum
// role elas podem retornar se você rodar assim.
populate_roles();
// Se precisar adicionar capabilities de forma mais granular,
// use esse formato:
$role = get_role( 'administrator' );
$role->add_cap( 'activate_plugins' ); // repetir com todas as caps desejadas
You only need to run this once. Check the results on the screen, then you can take out the functions again.
Here is a list of default capabilities for each user level.