private function getAuto( $user, $rawPassword, $extras, $trigger ) {
		$cbUser									=	new CBuser();

		$cbUser->load( (int) $user->id );

		if ( ( ! isset( $user->gids ) ) || ( isset( $user->gids ) && ( ! is_array( $user->gids ) ) ) ) {
			$gids								=	array( $user->gid );
		} else {
			$gids								=	$user->gids;
		}

		if ( $user->id ) {
			array_unshift( $gids, -3 );

			if ( isModerator( $user->id ) ) {
				array_unshift( $gids, -5 );
			} else {
				array_unshift( $gids, -4 );
			}
		} else {
			array_unshift( $gids, -2 );
		}

		array_unshift( $gids, -1 );

		$access									=	explode( '|*|', $trigger->get( 'access' ) );

		if ( ! array_intersect( $access, $gids ) ) {
			return;
		}

		$conditionals							=	count( explode( "\n", $trigger->get( 'field' ) ) );

		for ( $i = 0, $n = $conditionals; $i < $n; $i++ ) {
			if ( ! cbgjautoClass::getFieldMatch( $user, $cbUser, $extras, cbgjClass::getHTMLCleanParam( true, "field$i", null, null, $trigger->get( 'field' ) ), cbgjClass::getCleanParam( true, "operator$i", null, null, $trigger->get( 'operator' ) ), cbgjClass::getHTMLCleanParam( true, "value$i", null, null, $trigger->get( 'value' ) ) ) ) {
				return;
			}
		}

		$plugin									=	cbgjClass::getPlugin();
		$exclude								=	$trigger->get( 'exclude' );

		if ( $exclude ) {
			cbArrayToInts( explode( ',', $exclude ) );

			$exclude							=	array_unique( $exclude );

			if ( in_array( $user->id, $exclude ) ) {
				return;
			}
		}

		$params									=	$trigger->getParams();

		if ( ( $params->get( 'auto', null ) == 3 ) && $params->get( 'cat_name', null ) ) {
			$owner								=	(int) $cbUser->replaceUserVars( $params->get( 'cat_owner', $user->id ), true, true, $extras );

			if ( ! $owner ) {
				$owner							=	(int) $user->id;
			}

			$parent								=	(int) $params->get( 'cat_parent', 0 );
			$name								=	trim( strip_tags( $cbUser->replaceUserVars( $params->get( 'cat_name', null ), true, true, $extras ) ) );
			$description						=	$cbUser->replaceUserVars( $params->get( 'cat_description', null ), true, true, $extras );

			if ( $params->get( 'cat_unique', 1 ) ) {
				$where							=	array( array( 'user_id', '=', $owner ), array( 'name', '=', $name ), array( 'parent', '=', (int) $parent ) );
			} else {
				$where							=	array( array( 'name', '=', $name ), array( 'parent', '=', (int) $parent ) );
			}

			$row								=	cbgjData::getCategories( null, $where, null, null, false );

			if ( ! $row->get( 'id' ) ) {
				$row->set( 'published', 1 );
				$row->set( 'parent', (int) $parent );
				$row->set( 'user_id', $owner );
				$row->set( 'name', $name );

				if ( $plugin->params->get( 'category_editor', 1 ) >= 2 ) {
					$row->set( 'description', cbgjClass::getFilteredText( $description ) );
				} else {
					$row->set( 'description', trim( strip_tags( $description ) ) );
				}

				$row->set( 'access', (int) $plugin->params->get( 'category_access_default', -2 ) );
				$row->set( 'types', $params->get( 'types', $plugin->params->get( 'category_types_default', '1|*|2|*|3' ) ) );
				$row->set( 'create', (int) $plugin->params->get( 'category_create_default', 1 ) );
				$row->set( 'create_access', (int) $plugin->params->get( 'category_createaccess_default', -1 ) );
				$row->set( 'nested', (int) $plugin->params->get( 'category_nested_default', 1 ) );
				$row->set( 'nested_access', (int) $plugin->params->get( 'category_nestedaccess_default', -1 ) );
				$row->set( 'date', cbgjClass::getUTCDate() );
				$row->set( 'ordering', 99999 );

				$row->store();
			}
		} elseif ( ( $params->get( 'auto', null ) == 2 ) && $params->get( 'category', null ) && $params->get( 'grp_name', null ) ) {
			if ( ( $params->get( 'category', null ) == -1 ) && $params->get( 'cat_name', null ) ) {
				$owner							=	(int) $cbUser->replaceUserVars( $params->get( 'cat_owner', $user->id ), true, true, $extras );

				if ( ! $owner ) {
					$owner						=	(int) $user->id;
				}

				$parent							=	(int) $params->get( 'cat_parent', 0 );
				$name							=	trim( strip_tags( $cbUser->replaceUserVars( $params->get( 'cat_name', null ), true, true, $extras ) ) );
				$description					=	$cbUser->replaceUserVars( $params->get( 'cat_description', null ), true, true, $extras );

				if ( $params->get( 'cat_unique', 1 ) ) {
					$where						=	array( array( 'user_id', '=', $owner ), array( 'name', '=', $name ), array( 'parent', '=', (int) $parent ) );
				} else {
					$where						=	array( array( 'name', '=', $name ), array( 'parent', '=', (int) $parent ) );
				}

				$category						=	cbgjData::getCategories( null, $where, null, null, false );

				if ( ! $category->get( 'id' ) ) {
					$category->set( 'published', 1 );
					$category->set( 'parent', (int) $parent );
					$category->set( 'user_id', $owner );
					$category->set( 'name', $name );

					if ( $plugin->params->get( 'category_editor', 1 ) >= 2 ) {
						$category->set( 'description', cbgjClass::getFilteredText( $description ) );
					} else {
						$category->set( 'description', trim( strip_tags( $description ) ) );
					}

					$category->set( 'access', (int) $plugin->params->get( 'category_access_default', -2 ) );
					$category->set( 'types', $params->get( 'types', $plugin->params->get( 'category_types_default', '1|*|2|*|3' ) ) );
					$category->set( 'create', (int) $plugin->params->get( 'category_create_default', 1 ) );
					$category->set( 'create_access', (int) $plugin->params->get( 'category_createaccess_default', -1 ) );
					$category->set( 'nested', (int) $plugin->params->get( 'category_nested_default', 1 ) );
					$category->set( 'nested_access', (int) $plugin->params->get( 'category_nestedaccess_default', -1 ) );
					$category->set( 'date', cbgjClass::getUTCDate() );
					$category->set( 'ordering', 99999 );

					$category->store();
				}
			} else {
				$category						=	cbgjData::getCategories( null, array( 'id', '=', (int) $params->get( 'category', null ) ), null, null, false );
			}

			if ( $category->get( 'id' ) ) {
				$owner							=	(int) $cbUser->replaceUserVars( $params->get( 'grp_owner', $user->id ), true, true, $extras );

				if ( ! $owner ) {
					$owner						=	(int) $user->id;
				}

				$parent							=	(int) $params->get( 'grp_parent', 0 );
				$name							=	trim( strip_tags( $cbUser->replaceUserVars( $params->get( 'grp_name', null ), true, true, $extras ) ) );
				$description					=	$cbUser->replaceUserVars( $params->get( 'grp_description', null ), true, true, $extras );
				$join							=	false;

				if ( $params->get( 'grp_unique', 1 ) ) {
					$where						=	array( array( 'category', '=', (int) $category->get( 'id' ) ), array( 'user_id', '=', $owner ), array( 'name', '=', $name ), array( 'parent', '=', (int) $parent ) );
				} else {
					$where						=	array( array( 'category', '=', (int) $category->get( 'id' ) ), array( 'name', '=', $name ), array( 'parent', '=', (int) $parent ) );

					if ( $params->get( 'grp_autojoin', 1 ) ) {
						$join					=	true;
					}
				}

				$row							=	cbgjData::getGroups( null, $where, null, null, false );

				if ( ! $row->get( 'id' ) ) {
					$row->set( 'published', 1 );
					$row->set( 'category', (int) $category->get( 'id' ) );
					$row->set( 'parent', (int) $parent );
					$row->set( 'user_id', $owner );
					$row->set( 'name', $name );

					if ( $plugin->params->get( 'group_editor', 1 ) >= 2 ) {
						$row->set( 'description', cbgjClass::getFilteredText( $description ) );
					} else {
						$row->set( 'description', trim( strip_tags( $description ) ) );
					}

					$row->set( 'access', (int) $plugin->params->get( 'group_access_default', -2 ) );
					$row->set( 'type', (int) $params->get( 'type', $plugin->params->get( 'group_type_default', 1 ) ) );
					$row->set( 'nested', (int) $plugin->params->get( 'group_nested_default', 1 ) );
					$row->set( 'nested_access', (int) $plugin->params->get( 'group_nestedaccess_default', -1 ) );
					$row->set( 'date', cbgjClass::getUTCDate() );
					$row->set( 'ordering', 1 );

					if ( $row->store() ) {
						$row->storeOwner( $row->get( 'user_id' ) );

						if ( $row->get( 'user_id' ) !=  $user->id ) {
							$usr				=	cbgjData::getUsers( null, array( array( 'group', '=', (int) $row->get( 'id' ) ), array( 'user_id', '=', (int) $user->id ) ), null, null, false );

							if ( ! $usr->get( 'id' ) ) {
								$usr->set( 'user_id', (int) $user->id );
								$usr->set( 'group', (int) $row->get( 'id' ) );
								$usr->set( 'date', cbgjClass::getUTCDate() );
								$usr->set( 'status', 1 );
								$usr->store();
							}
						}
					}
				} elseif ( $join ) {
					$usr						=	cbgjData::getUsers( null, array( array( 'group', '=', (int) $row->get( 'id' ) ), array( 'user_id', '=', (int) $user->id ) ), null, null, false );

					if ( ! $usr->get( 'id' ) ) {
						$usr->set( 'user_id', (int) $user->id );
						$usr->set( 'group', (int) $row->get( 'id' ) );
						$usr->set( 'date', cbgjClass::getUTCDate() );
						$usr->set( 'status', (int) $params->get( 'status', 1 ) );

						if ( $usr->store() ) {
							if ( $usr->get( 'status' ) == 4 ) {
								$row->storeOwner( $usr->get( 'user_id' ) );
							}
						}
					}
				}
			}
		} elseif ( ( $params->get( 'auto', null ) == 1 ) && $params->get( 'groups', null ) ) {
			$groups								=	$params->get( 'groups', null );

			if ( $groups ) {
				$groups							=	explode( '|*|', $groups );

				cbArrayToInts( $groups );
			}

			if ( $groups ) foreach ( $groups as $groupId ) {
				$group							=	cbgjData::getGroups( null, array( 'id', '=', (int) $groupId ), null, null, false );

				if ( $group->get( 'id' ) ) {
					$row						=	cbgjData::getUsers( null, array( array( 'group', '=', (int) $group->get( 'id' ) ), array( 'user_id', '=', (int) $user->id ) ), null, null, false );

					if ( ! $row->get( 'id' ) ) {
						$row->set( 'user_id', (int) $user->id );
						$row->set( 'group', (int) $group->get( 'id' ) );
						$row->set( 'date', cbgjClass::getUTCDate() );
						$row->set( 'status', (int) $params->get( 'status', 1 ) );

						if ( $row->store() ) {
							if ( $row->get( 'status' ) == 4 ) {
								$group->storeOwner( $row->get( 'user_id' ) );
							}
						}
					}
				}
			}
		} elseif ( ( $params->get( 'auto', null ) == 4 ) && $params->get( 'groups', null ) ) {
			$groups								=	$params->get( 'groups', null );

			if ( $groups ) {
				$groups							=	explode( '|*|', $groups );

				cbArrayToInts( $groups );
			}

			if ( $groups ) foreach ( $groups as $groupId ) {
				$group							=	cbgjData::getGroups( null, array( 'id', '=', (int) $groupId ), null, null, false );

				if ( $group->get( 'id' ) ) {
					$row						=	cbgjData::getUsers( null, array( array( 'group', '=', (int) $group->get( 'id' ) ), array( 'user_id', '=', (int) $user->id ) ), null, null, false );

					if ( $row->get( 'id' ) && ( $row->get( 'status' ) != 4 ) ) {
						$row->deleteAll();
					}
				}
			}
		}
	}