I'm creating a custom pages and this is my actionIndex:
This code selects the highest user ID from the database and uses it as the highest value for the rand() function ($randUser variable). It then uses the random number as a user ID which is put in the getUserById function to return a user based on the random ID.
The user is then returned in the viewparams as $user.
This works fine, it spits out a result etc.
My next code:
This code works fine so far. It returns the user input (single text field) and puts it into the viewparams for use in templates - fine.
Now what I'm trying to do is compare the user input ($data['username']) in the actionAvatarCheck() function to the $user variable in the actionIndex() function.
In layman's terms: I want the $user variable in the first function to be available in the second function. I have no idea about variable scope and this is why I'm asking
Code:
public function actionIndex()
{
$maxUserId = XenForo_Application::get('db')->fetchRow("SELECT MAX(user_id) FROM xf_user");
$randUser = rand(1, $maxUserId['MAX(user_id)']);
$user = $this->getModelFromCache('XenForo_Model_User')->getUserById($randUser);
$viewParams = array(
'user' => $user
);
return $this->responseView('MyAddon_ViewPublic_Index', 'MyAddon_Index', $viewParams);
}
The user is then returned in the viewparams as $user.
This works fine, it spits out a result etc.
My next code:
Code:
public function actionAvatarCheck()
{
$data = $this->_input->filter(array(
'username' => XenForo_Input::STRING
));
$viewParams = array( 'data' => $data );
return $this->responseView('MyAddon_ViewPublic_AvatarCheck', 'MyAddon_Check', $viewParams);
}
Now what I'm trying to do is compare the user input ($data['username']) in the actionAvatarCheck() function to the $user variable in the actionIndex() function.
In layman's terms: I want the $user variable in the first function to be available in the second function. I have no idea about variable scope and this is why I'm asking
