How to add users under a specific role We have 4 type of users -

Admin   -  can view and manage all other users 
Parent  -  Can view and manage students but own child 
Teacher -  Can view and manage students assigned to him
Student -  Can view and manage own profile &amp; details


So it's clear that everything is around students can be accessed by 3 other roles as per rules.

I am trying with different role and users modules but not getting exactly how to setup this structure in drupal.

I am sure there is definitely a way to do this because it's a general requirement and drupal has a way to implement this. But I am newbie and trying from couple of hrs but not able to set this.

Anyone please guide me on this or share any link where I can get exact information regarding this.

Thanks is Advance
I assume you use something like Entity reference to add children to parents and to teachers.

I don't think that default Drupal supports this kind of user permissions. As I couldn't find any modules for this functionality, you probably need to do some coding.

The easiest approach would be altering the user/%uid/edit menu item with a custom access callback in a custom module. This ensures users can only access the user edit pages matching your criteria:

function MYMODULE_menu_alter(&amp;$items) {
 if (isset($items['user/%user/edit'])) {
   $items['user/%user/edit']['access callback'] = '_mymodule_user_edit_access';
  }
}

function _mymodule_user_edit_access($account) {
  global $user;

  // May edit own profile
  if ($account-&gt;uid == $user-&gt;uid) {
    return TRUE;
  }

  // Check if $user has permissions to edit $account
}


The access callback should check if the $user has role Teacher or Parent and if it is referencing to the $account->uid.

Edit:

I just realize you also need to manage profile view rights, this could be done with the same hook, on path user/%user.