//Whenever a user will be created \'user_register\' hook of WordPress is executed
add_action( \'user_register\', \'meta_registration_save\', 10, 1 );
//Following function will be called on each user registration and will save the \'created_by\' information in wp_usermeta table
function meta_registration_save( $user_id ) {
//logged in user
if ( is_user_logged_in() )
{
global $current_user;
get_currentuserinfo();
$current_id=$current_user->ID;
add_user_meta( $user_id, \'Created_by\', $id );
}
else{
//in case user is registered from non logged in user
add_user_meta( $user_id, \'Created_by\', 0 );
}
}
//To get the user meta details call following function
function get_creator_of_user($userid)
{
if(( $creator_id=get_user_meta ($userid, \'Created_by\',true) )!= 0)
echo get_user_meta ($creator_id, \'nickname\',true);
else
echo \'User created by non logged in user\';
}