I have a boolean in my table which is basically approved, but default it is FALSE
Users can click on the item in a grid and it fires a standard toggle and changes to true.. out the box J-Cook functionality
However I want to add an extra step which basiclcally adds the user into a USER GROUP (number 14 for the sake of argument)
I have found the toggle code
public function toggle()
{
CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
$this->_result = $result = $this->_toggle(array(
'toggle_approved' => 'approved'
));
$model = $this->getModel();
Where can I add an extra step in this which is basically
If you are toggling value to TRUE
(make sure to use $user = JFactory::getUser(); first)
Toggle the value AND
INSERT INTO #__user_usergroup_map (user_id,group_id)
VALUES ($user->id, 14)
or if toggling to FALSE
DELETE FROM #__user_usergroup_map WHERE user_id = $user->id AND group_id=14