Display user ID on the edit profile page
This example adds a read-only User ID brick that is available only for profile forms.
Add this code to site.php file:
Am_Di::getInstance()->hook->add(Am_Event::LOAD_BRICKS, function (Am_Event $event) {
class Am_Form_Brick_UserId extends Am_Form_Brick
{
public function __construct($id = null, $config = null)
{
$this->name = ___('User ID (readonly)');
parent::__construct($id, $config);
}
public function initConfigForm(Am_Form $form)
{
$form->addText('label')->setLabel(___('Label'));
}
public function insertBrick(HTML_QuickForm2_Container $form)
{
$data = array(
'content' => Am_Di::getInstance()->auth->getUserId(),
'label' => $this->getConfig('label', ___('User ID')),
);
$form->addStatic('user_id', null, $data);
}
public function isAcceptableForForm(Am_Form_Bricked $form)
{
return $form instanceof Am_Form_Profile;
}
}
});
Then edit the Profile form in aMember CP -> Forms Editor -> Edit Form and
add the User ID (readonly) brick to the profile form.