Difference between revisions of "How to display user id in edit profile page"

From aMember Pro Documentation
Jump to: navigation, search
Line 1: Line 1:
 
Add this code to [[site.php file]]:
 
Add this code to [[site.php file]]:
 
<source>
 
<source>
class Am_Form_Brick_UserId extends Am_Form_Brick
+
Am_Di::getInstance()->hook->add(Am_Event::LOAD_BRICKS, function(Am_Event $e){
{
+
    class Am_Form_Brick_UserId extends Am_Form_Brick
    public function __construct($id = null, $config = null)
+
 
     {
 
     {
         $this->name = ___('User ID (readonly)');
+
         public function __construct($id = null, $config = null)
        parent::__construct($id, $config);
+
        {
    }
+
            $this->name = ___('User ID (readonly)');
   
+
            parent::__construct($id, $config);
    public function initConfigForm(Am_Form $form) {
+
        }
        $form->addText('label')->setLabel(___('Label'));
+
 
    }
+
        public function initConfigForm(Am_Form $form) {
    public function insertBrick(HTML_QuickForm2_Container $form)
+
            $form->addText('label')->setLabel(___('Label'));
    {
+
        }
        $data = array();
+
 
        $data['content'] = Am_Di::getInstance()->auth->getUserId();
+
        public function insertBrick(HTML_QuickForm2_Container $form)
        $data['label'] = $this->getConfig('label');
+
        {
        $form->addStatic('user_id ', null, $data);
+
            $data = array();
    }
+
            $data['content'] = Am_Di::getInstance()->auth->getUserId();
      
+
            $data['label'] = $this->getConfig('label');
    public function isMultiple()
+
            $form->addStatic('user_id', null, $data);
    {
+
        }
        return true;
+
     }
    }
+
});
}
+
 
</source>
 
</source>
  
  
 
Then edit Profile form in aMember CP -> Forms Editor -> Edit Form and add User ID brick to profile form.
 
Then edit Profile form in aMember CP -> Forms Editor -> Edit Form and add User ID brick to profile form.

Revision as of 08:32, 29 February 2016

Add this code to site.php file:

Am_Di::getInstance()->hook->add(Am_Event::LOAD_BRICKS, function(Am_Event $e){
    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();
            $data['content'] = Am_Di::getInstance()->auth->getUserId();
            $data['label'] = $this->getConfig('label');
            $form->addStatic('user_id', null, $data);
        }
    } 
});


Then edit Profile form in aMember CP -> Forms Editor -> Edit Form and add User ID brick to profile form.