Advertisement:

Author Topic: Required Registration Plugin  (Read 613 times)

AndyB123

  • Newbie
  • *
  • Posts: 24
Required Registration Plugin
« on: November 21, 2018, 08:29:03 pm »
Hi I have installed the Required Registration plugin to add a user phone number upon registration. However, it is not making the phone number required and users are able to register without filling in this option. How do I make it compulsory like all other fields? https://tradesconnect.ie/user/register

Thanks!


calinbehtuk

  • Sr. Member
  • ****
  • Posts: 447
Re: Required Registration Plugin
« Reply #1 on: November 22, 2018, 11:31:43 am »
In functions.php on bottom in your active theme, before of php ending tag ?> if this tag exists

Code: [Select]
function phone_check_registration() {
    $phone = Params::getParam('s_phone_mobile');
    if (empty($phone)) {
        osc_add_flash_error_message( __('Please fill the phone field.'));
        header("Location: " . osc_register_account_url());
    }
}

osc_add_hook('before_user_register', 'phone_check_registration');


AndyB123

  • Newbie
  • *
  • Posts: 24
Re: Required Registration Plugin
« Reply #2 on: November 22, 2018, 03:34:39 pm »
Hi thanks for the reply!

I have inserted this. However, it is still allowing you to register without the phone number. Any other suggestions?

Regards

Andy

JAVIERSL70

  • Newbie
  • *
  • Posts: 9
Re: Required Registration Plugin
« Reply #3 on: December 07, 2018, 03:28:15 pm »
I have tried that solution in my template and it has not worked for me.
It shows the message that you have to fill in the field of the phone, but also shows the message that the account has been created.

:-(

calinbehtuk

  • Sr. Member
  • ****
  • Posts: 447
Re: Required Registration Plugin
« Reply #4 on: December 07, 2018, 03:51:28 pm »
Code: [Select]
function phone_check_registration() {
    $phone = Params::getParam('s_phone_mobile');
    if (empty($phone)) {
        osc_add_flash_error_message( __('Please fill the phone field.'));
        header("Location: " . osc_register_account_url());
       exit();
    }
}

osc_add_hook('before_user_register', 'phone_check_registration');

JAVIERSL70

  • Newbie
  • *
  • Posts: 9
Re: Required Registration Plugin
« Reply #5 on: December 07, 2018, 04:15:38 pm »
Yes, I tried putting that code at the end of the file's functions.php file of my theme, and what happens is what I described earlier.

calinbehtuk

  • Sr. Member
  • ****
  • Posts: 447
Re: Required Registration Plugin
« Reply #6 on: December 07, 2018, 04:18:39 pm »
I change the code, you have exit() function  in that code

JAVIERSL70

  • Newbie
  • *
  • Posts: 9
Re: Required Registration Plugin
« Reply #7 on: December 07, 2018, 06:34:12 pm »
Perfect! Now if it works correctly!
Thank you!

JAVIERSL70

  • Newbie
  • *
  • Posts: 9
Re: Required Registration Plugin
« Reply #8 on: December 07, 2018, 07:21:37 pm »
Now there is a problem to choose the country and the regions, you have to write it down. A selection box is not displayed.

calinbehtuk

  • Sr. Member
  • ****
  • Posts: 447
Re: Required Registration Plugin
« Reply #9 on: December 07, 2018, 07:43:32 pm »
Now there is a problem to choose the country and the regions, you have to write it down. A selection box is not displayed.
This code doesn't affect you register page in any way, this code will run before the data is save in database, so no change on register page.
By default osclass has no country selection on register from, so your theme or the plugin you use to add those fields on that form has no option to handle the error, if an error is accured and you go back on register page.
Or maybe your theme or plugin has a js validation but only for that fields(Country, Region, City) and not for phone field. In this case you have to change the js validation function and add a validation for phone also there. Or maybe i am wrong and you have other issue there.
In each case this code has nothing to do with the registration form, the code only return the user on register page if you have no phone in that field. The rest you need to figure out yourself.