• eldeuce

    (@eldeuce)


    I was wondering if there is a way to add a check system to the users.php so that users are only allowed to edit users below their current level.
    So Admin can Edit anyone, Editors can only edit below Editor, not other Editors, etc.

    I have put in a plugin that allows me to give Editors access to Add/Edit/Delete users, but unfortuantly it also gives Editors the ability to remove Admin.

    Shouldn’t be too hard for someone who knows the core files to add a little bit of a check system.

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • If there’s only one Admin (with userID #1) try this….

    In /wp-admin/menu.php add this code at the top:

    $SuperAdmin = '';
    
    if($user_ID==1)
    	{ $SuperAdmin = 'Y'; }

    Then you can use “if($SuperAdmin) { include only what SuperAdmin can do }” throughout the wp-admin files and menus.

    For the /wp-admin/users.php limitation you requested, I just disable all display of Administrators by adding this code after <table class=”widefat”>:

    <?
    foreach($roleclasses as $role => $roleclass)
    	{
    	uksort($roleclass, "strnatcasecmp");
    
    	$NoShow = '';
    
    	if($wp_roles->role_names[$role]=='Administrator')
    		{ $NoShow = 'Y'; }
    
    	if(!$NoShow)
    		{
    		echo '<tbody><tr>';
    
    		if(!empty($role)) :
    
    			echo '<th colspan="7"><h3>' .
    			$wp_roles->role_names[$role] . $NoShow .
    			'</h3></th>';
    
    		else :
    
    			echo '<th colspan="7"><h3><em>' .
    			'No role for this blog</em></h3></th>';
    
    		endif;
    
    		echo '</tr><tr class="thead">' .
    
    			'<th>ID</th>' .
    			'<th>Username</th>' .
    			'<th>Name</th>' .
    			'<th>E-mail</th>' .
    			'<th>Website</th>' .
    			'<th colspan="2" style="text-align: center">Actions</th>' .
    
    		'</tr></tbody>' .
    
    		'<tbody id="role-' . $role . '">';
    
    		$style = '';
    
    		foreach((array) $roleclass as $user_object)
    			{
    			$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
    			echo user_row($user_object, $style);
    			}
    
    		echo '</tbody>';
    		}
    	}
    
    echo '</table>';

    Hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘users.php mods’ is closed to new replies.