Skip Navigation

[Resolved] Split: Split: How to validate specific email domain with forms and email domain post type

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 1 year, 8 months ago.

Assigned support staff: Minesh.

Author
Posts
#1376919

Hi Minesh,

My client has updated this site and now wishes to add a large number of approved email domains. Isn't there a way to do validation within Toolset, using Toolset logic? I need to be able to create a custom post type for Approved Domains, which the client can edit and maintain.

Then, I need to be able to redirect entries based on whether their email domain is one of these custom post types or not. It would certainly be great if there was a validation editor for forms, similar to that for views. Is there any way to obtain this functionality that would preclude writing any custom PHP functions?

#1376925

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

My client has updated this site and now wishes to add a large number of approved email domains. Isn't there a way to do validation within Toolset, using Toolset logic? I need to be able to create a custom post type for Approved Domains, which the client can edit and maintain.
==>
Yes, you should create a custom post type for approved domains. You can do this with Toolset.

Then, I need to be able to redirect entries based on whether their email domain is one of these custom post types or not. It would certainly be great if there was a validation editor for forms, similar to that for views. Is there any way to obtain this functionality that would preclude writing any custom PHP functions?
===>
At this step you need to make a little change.

The following code needs to be changed that is I shared in previous ticket:

function validate_email_domain($email){
  if (!preg_match('/^([a-z0-9\+\_\-\.]+)@([a-z0-9\+\_\-\.]{2,})(\.[a-z]{2,4})$/i', $email)) return false;
 
  $domains = array('gmail.com','yahoo.com','hotmail.com');
  list(, $email_domain) = explode('@', $email, 2);
  return !in_array($email_domain, $domains);
}

As you can see we are checking with static domains.

$domains = array('gmail.com','yahoo.com','hotmail.com');

You should query all posts for your new post type you create that holds the Approved Domains and assign to $domains. I