Hi,
poke @bnomei
I try to get user id in a Janitor jobs to update user page fields when clicking on a Janitor button, but $data return an empty String.
May we get data from a user blueprint and pass it to a Janitor job?
This is my code:
/blueprints/users/journalist.yml
fields:
updateJournalistValidated:
type: janitor
label: Modifications du journaliste contrôlées
icon: smile
job: updateJournalistValidated
data: '{{ user.id }}'
when:
journalistState: update
config.php
'updateJournalistValidated' => function (Kirby\Cms\Page $page = null, string $data = null ) {
$kirby = kirby();
$kirby->impersonate();
var_dump($data);
$journalist = $kirby->user( $data );
if ( !empty( $journalist ) ) :
$kirby->impersonate();
$user->update([
'journalistState' => '',
'updateJournalistValidatedInfo' => '',
]);
endif;
return [
'status' => 200,
'reload' => true,
];
},
Thanks for any help
From looking at the source code, the data property only works for page and file models, not for users.
Maybe create a feature request for user support (or extend it yourself for the time being)
1 Like
Thanks @texnixe for this confirmation. I’m going to suggest to Bruno an enhancement in its Github repo.
bnomei
4
quick hack… might work. i have no time to test it today.