To make email an optional field

  • bumble
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
11 months 4 weeks ago #157814 by bumble
To make email an optional field was created by bumble
Hi there, is there a way to make the email field an optional field in the membership form?

Please Log in or Create an account to join the conversation.

More
11 months 4 weeks ago #157817 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic To make email an optional field
Hello

Email is needed for Joomla to create user account, also, to send email to subscriber when they subscribe, when they need to renew subscription..., so it could not be optional

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • bumble
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
11 months 4 weeks ago #157818 by bumble
Replied by bumble on topic To make email an optional field
We do not need the members to have a Joomla user account.
To email them only if they put in their email address.
Is there a way to work around this?

Please Log in or Create an account to join the conversation.

More
11 months 4 weeks ago #157823 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic To make email an optional field
Hello

Please try to edit the field:

1. Set Required to No

2. Set Validation Rules to validate[custom

Please Log in or Create an account to join the conversation.

  • bumble
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
11 months 4 weeks ago #157829 by bumble
Replied by bumble on topic To make email an optional field
Edited the field but getting this message:
The field Email is required. You could not leave it empty
The email address you entered is invalid. Please enter another email address.

Please Log in or Create an account to join the conversation.

More
11 months 4 weeks ago #157844 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic To make email an optional field
It is because the code is implemented with email as a required field for the system to work. I will see if there is a way to make it optional for you, but I'm afraid of it will require modify code in different places in the extension

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • bumble
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
11 months 4 weeks ago #157845 by bumble
Replied by bumble on topic To make email an optional field
Ok appreciate your help looking into this. Just let me know where to edit the codes. Thank you!

Please Log in or Create an account to join the conversation.

More
11 months 4 weeks ago #157846 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic To make email an optional field
Hi

Please try to look at the file components/com_osmembership/model/register.php , modify this line of code at line 414:
Code:
$errors = array_merge($errors, $this->validateEmail($email, $createUserAccount));

To
Code:
if ($email) { $errors = array_merge($errors, $this->validateEmail($email, $createUserAccount)); }

Then check to see if it works

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • bumble
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
11 months 3 weeks ago #157871 by bumble
Replied by bumble on topic To make email an optional field
Nice! It seems to work! Thank you very much!

Please Log in or Create an account to join the conversation.

More
11 months 3 weeks ago #157884 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic To make email an optional field
The downside is that change will be lost when you update to future releases of Membership Pro. Maybe you can try the following solution :

1. Revert the change you made

2. Get this file, unzip it, upload the received file to components/com_osmembership/model/override folder, then check to see if it works

Regards,

Tuan
Attachments:

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc