WordPress – Permettere ad un Amministratore di modificare gli utenti in modalità Network

Se disponiamo di un sito web (WordPress) in modalità Network …e vogliamo che un amministratore di un “singolo” sito web sia in  grado di modificare/gestire (edit) i propri utenti, è necessario apportare delle modifiche “fisiche” a Wordpress.

File da modificare : wp-includes/capabilities.php
E’ necessario aggiungere una funzione a questo files, abbastanza corposa. Può essere aggiunta subito in “testa” a partire dalla riga1.
La funzione è la seguente:

[php]

function mc_admin_users_caps( $caps, $cap, $user_id, $args ){

foreach( $caps as $key => $capability ){

if( $capability != 'do_not_allow' )
continue;

switch( $cap ) {
case 'edit_user':
case 'edit_users':
$caps[$key] = 'edit_users';
break;
case 'delete_user':
case 'delete_users':
$caps[$key] = 'delete_users';
break;
case 'create_users':
$caps[$key] = $cap;
break;
}
}

return $caps;
}
add_filter( 'map_meta_cap', 'mc_admin_users_caps', 1, 4 );
remove_all_filters( 'enable_edit_any_user_configuration' );
add_filter( 'enable_edit_any_user_configuration', '__return_true');

/**
* Checks that both the editing user and the user being edited are
* members of the blog and prevents the super admin being edited.
*/
function mc_edit_permission_check() {
global $current_user, $profileuser;

$screen = get_current_screen();

get_currentuserinfo();

if( ! is_super_admin( $current_user->ID ) && in_array( $screen->base, array( 'user-edit', 'user-edit-network' ) ) ) { // editing a user profile
if ( is_super_admin( $profileuser->ID ) ) { // trying to edit a superadmin while less than a superadmin
wp_die( __( 'You do not have permission to edit this user.' ) );
} elseif ( ! ( is_user_member_of_blog( $profileuser->ID, get_current_blog_id() ) && is_user_member_of_blog( $current_user->ID, get_current_blog_id() ) )) { // editing user and edited user aren't members of the same blog
wp_die( __( 'You do not have permission to edit this user.' ) );
}
}

}
add_filter( 'admin_head', 'mc_edit_permission_check', 1, 4 );

[/php]

File da modificare : wp-config.php
Aggiungere la seguente direttiva : define(‘EDIT_ANY_USER’, true );

Seguici su:

FacebookLinkedInLinkedInLinkedIn

Potrebbero Interessarti anche:

    Per maggiori informazioni, per suggerimenti e ottenere un preventivo gratuito per le tue esigenze, contatta la nostra Web Agency.
    Il nostro staff di professionisti sarà lieto di fornire tutte le informazioni ed i costi riguardanti il servizio.
    Attenzione : Webx.it non è un servizio di helpdesk “gratuito” a cui chiedere informazioni.

    WebMaster Firenze

    Fonti : WordPress Network Administrator Edit user, Allow Wordpress Network Administrator Edit user, permettere ad un amministratore di modificare utenti WordPress Network, amministratore editare utenti WordPress Network, abilitare amministratore modificare utenti WordPress modalità Network, consentire ad un amministratore di modificare utenti WordPress Network

    Previous Post Previous Post
    Newer Post Newer Post
    Hai bisogno di Aiuto?
    Invia via WhatsApp