103 Posts
Osep45
6 years ago
2
Topic

Hello, 

In my site form, people can publish articles when they are not connected and some people have user name and code. 

When user connected publish an article, the field art_catid is visible and configured by default on value 38. But they can change the catid. 

When people are not connected, the field art_catid is not visible and I would like the catid automatically filled with value '11'.

--> In the site form in admin, the field catid is in restricted access only for connected people. BUT then, when not connected people publish an article the field catid is empty...

I tried to solve this with an "after (or before?) store field with this code :

$username = JFactory::getUser()->name;

if ( ($config['isNew']) || ($username !='name-connected') ) {

$name = $fields['art_catid']->storage_field;
$table = $fields['art_catid']->storage_table;
$new_value = '11';
$config['storages'][$table][$name] = $new_value;
$fields['art_catid']->value = $new_value;
}

but nothing happens... Would you know how I could do this ?

Thanks !!

Get a VIP membership
4229 Posts
Kadministrator
6 years ago
0
Level 1

In after store nothing will happen for sure as, well, it happens after save to db has already happened. To modify values that get saved you need to use beforeStore.

1283 Posts
Bucklash
6 years ago
0
Level 1

If you are saying that your live value is not working for your catid, then try and use select dynamic to pull the categories... 

Get a VIP membership