I have the following code as a PHP form plugin and it always worked until recently. Any idea why it would no longer work? Image attached showing settings for this plugin.
// get current user
$user = JFactory::getUser();
$userid = $user->get('id');
$groups = $user->groups;
// add the new group 10 if it isn't already there
if ( !in_array(10, $groups) ) {
$groups[] = 10;
}
// remove group 13 if it is present
if ( ($key = array_search(13, $groups) ) !== false ) {
unset($groups[$key]);
}
// save the new groups array
$user->groups = $groups;
$user->save();
// Get the db object
$myDb = JFactory::getDbo();
// Build the query
$myQuery = $myDb->getQuery(true);
$myQuery
->update('#__comprofiler')
->set('cb_usertype = "h"')
->where('id = '.(int)$userid);
$myDb->setQuery($myQuery);
// Run the query
$myDb->execute();
$app = JFactory::getApplication();
$error = $app->logout();
JFactory::getApplication()->redirect('index.php?option=com_content&view=article&id=422&Itemid=455&lang=jp');
// get current user
$user = JFactory::getUser();
$userid = $user->get('id');
$groups = $user->groups;
// add the new group 10 if it isn't already there
if ( !in_array(10, $groups) ) {
$groups[] = 10;
}
// remove group 13 if it is present
if ( ($key = array_search(13, $groups) ) !== false ) {
unset($groups[$key]);
}
// save the new groups array
$user->groups = $groups;
$user->save();
// Get the db object
$myDb = JFactory::getDbo();
// Build the query
$myQuery = $myDb->getQuery(true);
$myQuery
->update('#__comprofiler')
->set('cb_usertype = "h"')
->where('id = '.(int)$userid);
$myDb->setQuery($myQuery);
// Run the query
$myDb->execute();
$app = JFactory::getApplication();
$error = $app->logout();
JFactory::getApplication()->redirect('index.php?option=com_content&view=article&id=422&Itemid=455&lang=jp');