$username = ym_post('username', $email_address);
            $password = ym_post('password');
            $c_password = ym_post('c_password');
            $sub_id = ym_post('package', false);
            $package_type = ym_post('package_type', false);
            if (ym_group_membership_create_child($email_address, $username, $password, $c_password, $sub_id, $package_type, TRUE)) {
                // reload
                $ym_user = new YourMember_User($ym_user->ID);
            }
        } else {
            ym_display_message(__('Unknown Action Requested', 'ym'), 'error');
        }
    }
}
// get breakdown
$current_counts = ym_group_membership_get_counts();
echo '<div id="poststuff" class="wrap">
	<h2>' . __('Group Membership', 'ym') . '</h2>';
ym_box_top('&nbsp;');
echo '<p>' . sprintf(__('You are eligible to have %s account%s in your Group, you currently have %s Child Account%s', 'ym'), $ym_user->child_accounts_allowed, $ym_user->child_accounts_allowed != 1 ? 's' : '', count($ym_user->child_ids), count($ym_user->child_ids) != 1 ? 's' : '') . '</p>';
echo '
<table class="form-table widefat">';
if (count($ym_user->child_ids)) {
    echo '<tr>
		<th>' . __('User Email', 'ym') . '</th>
		<th>' . __('User Login', 'ym') . '</th>
		<th>' . __('Package Type', 'ym') . '</th>
		<th>' . __('Status, click to Toggle', 'ym') . '</th>
		<th>' . __('Delete', 'ym') . '</th>
	</tr>';
    foreach ($ym_user->child_ids as $child) {
function ym_group_membership_create_child($email_address, $username, $password, $c_password, $sub_id, $package_type = false, $message = FALSE, $parent_id = FALSE)
{
    if ($parent_id) {
        $ym_user = new YourMember_User($parent_id);
    } else {
        global $ym_user;
    }
    $current_counts = ym_group_membership_get_counts($ym_user);
    if (count($ym_user->child_ids) >= $ym_user->child_accounts_allowed) {
        if ($message) {
            ym_display_message(__('You are out of Child Accounts', 'ym'), 'error');
        }
        return FALSE;
    } else {
        if ($email_address && is_email($email_address)) {
            if (!empty($password) && $password != $c_password) {
                ym_display_message(__('Passwords do not match', 'ym'), 'error');
            }
            if ($sub_id) {
                if (!in_array($sub_id, $ym_user->child_accounts_packages)) {
                    if ($message) {
                        ym_display_message(__('You do not have access to this pacakge', 'ym'), 'error');
                    }
                    return FALSE;
                }
                $pack = ym_get_pack_by_id($sub_id);
            } else {
                if ($package_type) {
                    $pack = array();
                    $pack['account_type'] = $package_type;
                } else {
                    // inherit mode
                    $pack = array();
                    $pack['account_type'] = $ym_user->account_type;
                }
            }
            $inherit = true;
            foreach ($ym_user->child_accounts_package_types as $type => $type_count) {
                if ($type_count) {
                    $inherit = false;
                }
            }
            //			if ($inherit) {
            //				$pack['account_type'] = '';
            //			}
            if ($pack['account_type'] && $ym_user->child_accounts_package_types[$pack['account_type']] > $current_counts[$pack['account_type']] || $inherit && $ym_user->child_accounts_allowed > count($ym_user->child_ids)) {
                $new_user = new YourMember_User();
                $result = $new_user->create($email_address, $sub_id, FALSE, $username, $password);
                if (is_wp_error($result)) {
                    ym_display_message($result->get_error_message(), 'error');
                } else {
                    // apply child
                    $data = array('parent_id' => $ym_user->ID, 'account_type' => $pack['account_type'], 'status_str' => __('Child Account', 'ym'));
                    if (!$sub_id) {
                        // the child has inherited they won't have a role!
                        $new_user->updaterole('subscriber');
                    }
                    $new_user->update($data);
                    $new_user->save();
                    unset($new_user);
                    //garbage collect
                    $child_ids = $ym_user->child_ids;
                    $child_ids[] = $result;
                    $ym_user->update(array('child_ids' => $child_ids));
                    $ym_user->save();
                    @ym_log_transaction(YM_ACCOUNT_TYPE_ASSIGNATION, __('Child', 'ym') . ' ' . $data['account_type'], $result);
                    @ym_log_transaction(YM_USER_STATUS_UPDATE, YM_STATUS_ACTIVE . ' - ' . $data['status_str'], $result);
                    // all done
                    if ($message) {
                        ym_display_message(__('Child User was created successfully', 'ym'));
                    }
                    return TRUE;
                }
            } else {
                if ($message) {
                    ym_display_message(__('Total for this package type has been reached', 'ym'), 'error');
                }
                return FALSE;
            }
        } else {
            if ($message) {
                ym_display_message(__('The Email Address was Blank or Invalid', 'ym'), 'error');
            }
            return FALSE;
        }
    }
}