How to create a module that changes other modules' behaviors

27 Views Asked by At

I want to create a module for SocialEngine that changes the signup behavior by adding the option to signup using phone number and sending text message to the user's phone and letting them confirm it. I guess I need to add code in the file application/modules/User/Form/Signup.php. For example, I can add a new field as follows:

$this->AddElement('Text', 'sms', [
    'class' => 'signup-name',
    'label' => 'Phone Number',
    'required' => true,
    'validators' => [
        ['StringLength', true, ['min'=>11, 'max'=>11]]
    ]
        ]
);

$this->sms->getValidator('StringLength')->setMessage('Phone must be 11 digits');

However, I don't want to manually add the code. I need to add the functionality by installing the plugin and disable it by removing or disabling the plugin. How can I do that?
Do I need to mess with installation php scripts and do file operations like overwriting files or is there a better way to separate my files completely, meanwhile making them serve as a complement for a given module?

0

There are 0 best solutions below