Jump to content

Edit History

Andrei H

Andrei H

Hello,

@elly63, my solution should hopefully work on both 1.7 and 8 (I have tested it only with 8, but if you are trying it with 1.7 and it does not work, I can look into that)

The hook that's called before the registration process is called 'hookActionSubmitAccountBefore'

You can either register it in your current module or create a new one only for it, that's up to you.

Once the hook is registered by the module, you just need to add the following lines of code inside the module's main class:

public function hookActionSubmitAccountBefore()
{
    if (Tools::getIsset('id_gender')) {
        Tools::redirect('/');
    } 

    return true;
}

As you can see, the logic is fairly simple. This code checks if the 'id_gender' field was set. If it was set, it will redirect the customer to the home page. Otherwise just return true so that the registration process can continue.

You should test this in a non-prod environment first.

If you have any troubles with registering the hook or you want to execute a different logic inside it, just let me know and I'll have a look into it.

Andrei H

Andrei H

Hello,

@elly63,  my solution should hopefully work on both 1.7 and 8 (I have tested it only with 8, but if you are using 1.7 and it does not work, I can look into that)

The hook that's called before the registration process is called 'hookActionSubmitAccountBefore'

You can either register it in your current module or create a new one only for it, that's up to you.

Once the hook is registered by the module, you just need to add the following lines of code inside the module's main class:

public function hookActionSubmitAccountBefore()
{
    if (Tools::getIsset('id_gender')) {
        Tools::redirect('/');
    } 

    return true;
}

As you can see, the logic is fairly simple. This code checks if the 'id_gender' field was set. If it was set, it will redirect the customer to the home page. Otherwise just return true so that the registration process can continue.

You should test this in a non-prod environment first.

If you have any troubles with registering the hook or you want to execute a different logic inside it, just let me know and I'll have a look into it.

Andrei H

Andrei H

Hello,

@elly63, you did not mention the PrestaShop version you are using, but my solution should hopefully work on both 1.7 and 8 (I have tested it only with 8, but if you are using 1.7 and it does not work, I can look into that)

The hook that's called before the registration process is called 'hookActionSubmitAccountBefore'

You can either register it in your current module or create a new one only for it, that's up to you.

Once the hook is registered by the module, you just need to add the following lines of code inside the module's main class:

public function hookActionSubmitAccountBefore()
{
    if (Tools::getIsset('id_gender')) {
        Tools::redirect('/');
    } 

    return true;
}

As you can see, the logic is fairly simple. This code checks if the 'id_gender' field was set. If it was set, it will redirect the customer to the home page. Otherwise just return true so that the registration process can continue.

You should test this in a non-prod environment first.

If you have any troubles with registering the hook or you want to execute a different logic inside it, just let me know and I'll have a look into it.

×
×
  • Create New...