set Value of custom field by plugin

  • Posts: 134
  • Thank you received: 3
1 day 59 minutes ago #364475

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


Joomla Developer | am.ebrahimzadeh[at]gmail.com

Please Log in or Create an account to join the conversation.

Time to create page: 0.053 seconds
Powered by Kunena Forum