I am creating a custom web using WordPress. I need to get information about who has created an account/user.

The meta for example created_by. So that I can retrieve who are the users that created by user X and who are the user created by Y and so on.

//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;
        add_user_meta( $user_id, 'Created_by', $id );
        //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);

        echo 'User created by non logged in user';

Not the answer you're looking for? Browse other questions tagged or ask your own question.