Post eval for update cols plugin

thellie

Member
Hey, it's been a while...

I'm setting up an admin dbase for our Thai intern students. Applicants fill in a form, which generates a record and their usergroup is pre-set to 'Pending decision' (usergroup 12).

A staff member then decides whether we will accept the application. I have set up an element '{application decision}' for the staff member to input the final decision:
'Pending' (which is the default status)
'Pass'
'Fail'
I have added a PHP form plugin to change the usergroup status to reflect the change in application status:
If 'Pass', usergroup changes to 'Intern' (usergroup 10)
If 'Fail', usergroup changes to 'Registered' (usergroup 2)


To make it easier, as we have quite a number of interns, I want to be able to change multiple rows rather than going into each form individually...

I have created update cols plugins, one for each possible decision. It works correctly as far as changing the '{application decision}' element - but as I don't open the form the PHP form plugin is not run (correct?).

I tried adding the PHP code to the post-eval field in the Update Cols plugin, but it does not change the usergroup.

Anyone have an idea how to do this using the Update cols plugin, in a single step (change status + change usergroup)? If not, I'll leave it so the staff member has to update each form individually, running the PHP form plugin instead.

FYI
Code:
// Get the connected user
$user = '{interns___intern_id}';
$decision = '{interns___application_decision_raw}';

if($decision === 'thumbsdown') {
// set the user in group ID = x
JUserHelper::setUserGroups($user, array(2) );
/* reload the user object so the user gets logged out
$session = JFactory::getSession();
$session->set('user', new JUser($user)); */
}
elseif($decision === 'thumbsup') {
// set the user in group ID = x
JUserHelper::setUserGroups($user, array(10) );
/* reload the user object so the user gets logged out
$session = JFactory::getSession();
$session->set('user', new JUser($user)); */
}
elseif($decision === 'pending') {
// set the user in group ID = x
JUserHelper::setUserGroups($user, array(12) );
/* reload the user object so the user gets logged out
$session = JFactory::getSession();
$session->set('user', new JUser($user)); */
}
else {};
Thanks :)
 
The post-eval is not "per row" but running once, you can't use placeholders.

The tooltip in pre-eval says ".... Ids are in $ids, data is in $data" so I tried with debugging and got (in post-eval)
$data[0] as the array of row objects

You should be able to do something like
foreach ($data[0] as $rowdata)
{
...
$user = $rowdata->interns___intern_id;
...
}
 
My PHP coding is no better than last year...

I put this in the post eval, but the usergroup is not updated. I guess there should be more code in there for it to work...

Code:
foreach ($data[0] as $rowdata)
{
$user = $rowdata->interns___intern_id;
// set the user in group ID = x
JUserHelper::setUserGroups($user, array(12) );
}

I won't waste your time, but just stick with the slower form-by-form method.

Thanks for putting the time in though, it's appreciated :)
 
Try $rowdata->interns___intern_id_raw. It's likely that the non _raw is the username, or has some formatting.

-- hugh
 
I'd already tried that Hugh...

I think now that it's a different issue, but am (unsurprisingly) stumped.

I've just been attempting to create some volunteer certificates in another website, which uses the article form plugin and article list button plugin. This button is also not working, but the article form plugin works correctly when saving the form record.

It seems to be an issue with the buttons created for the list - update_col and article are the two I use and neither works (article was working correctly when I last used it 3-4 weeks ago).

Both sites are updated to J!3.9.4
 
Intern website
update_col list plugin works correctly, but I cannot get the post eval to work (to set usergroup)
PHP form plugin (to set usergroup) works correctly for each individual record

but... MY BAD for this one...
Article list plugin IS working correctly - I thought it created as well as updated articles... the update works. Sorry.:oops:
 
You can use the jdump extension (or var_dump(...);exit; and your browsers network response tab) for debugging to see what you really get in $data in your case.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top