hello,
I have a custom field (dropdown) on User cloumn.
I want set default value and readonly it by plugin.
my plugin codes:
<?php
defined('_JEXEC') or die;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Factory;
class PlgSystemHikaShopCustomize extends CMSPlugin
{
public function onHikashopBeforeDisplayView(&$view)
{
// Only modify the user registration form view
if ($view->getName() !== 'user' || $view->getLayout() !== 'form') {
return;
}
$user = Factory::getUser();
// Check if the logged-in user is in the 'Teacher' group (group ID 15)
if (in_array(15, $user->getAuthorisedGroups())) {
// Ensure Hikashop helper is loaded
if (!class_exists('hikashopFieldClass')) {
if (!include_once(JPATH_ADMINISTRATOR . '/components/com_hikashop/helpers/helper.php')) {
return;
}
}
$class = hikashop_get('class.field');
$field = $class->getField('teacher_name', 'user');
$lenew = new stdClass();
$lenew->value = "azur";
$lenew->disabled = 0;
$field->field_value['bleue'] = $lenew;
$class->addValue($field->field_id, 'bleue', 'azur', 0);
}
}
}
But i not working as well. can you help me? thank you