Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Only allowing some emails to create an account [closed]

Just copy the above code and paste it into your theme’s functions.php file.
Here I am going to show you the code which will reject registration from all others domain’s email addresses and Only allowing @uniname.ac.uk email addresses to create an account. See the code below

function is_valid_email_domain($login, $email, $errors ){
    $valid_email_domain = array("uniname.ac.uk");
    $valid = false;
    foreach( $valid_email_domain as $d ){
        $d_length = strlen( $d );
        $current_email_domain = strtolower( substr( $email, -($d_length), $d_length));
        if( $current_email_domain == strtolower($d) ){
            $valid = true;
            break;
        }
    }
    if( $valid === false ){
        $errors->add('domain_whitelist_error',__( '<strong>ERROR</strong>: you can only register using @uniname.ac.uk emails' ));
    }
}
add_action('register_post', 'is_valid_email_domain',10,3 );

Related Posts:

  1. how to change the verification url of pie register plugin of wordpress?
  2. WooCommerce get_price returning wrong price when used via ajax
  3. How to ‘clone’ a wp plugin to make small changes
  4. Open Post Thumbnail in New Child Theme File in WordPress
  5. add mediaelement.js plugins into WordPress video player control bar
  6. Shortcode button dosent work for all posts. Work for first post only
  7. Where should I save an API key of my user when installing my plugin?
  8. Prevent a plugin from being automatically activated
  9. Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
  10. Programatically download a plugin
  11. Accessing post’s meta data based on user’s click of a post
  12. Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
  13. Preferred way of cacheing a value in php
  14. Redirecting to home page after login as custom role WordPress
  15. WordPress Redirect Not Working – AJAX Callback Response Not Picked Up
  16. How to Use Parameters with a Do_Action Function Within PHP Tags
  17. Add keywords meta to index.php page
  18. Custom form action to handle data inside a plugin
  19. Only allowing some email addresses to create an account
  20. How to remove html code in excel downloads using phpspreadsheet with wordpress plugins shortcode
  21. Add Product Subtitle to Woocommerce Product Page
  22. Self deactivate plugins after an action occurs
  23. wp_redirect() not working in Insert PHP plugin in WordPress
  24. Download any file after submitting a form [closed]
  25. Pulling data from custom plugin settings using PHP shortcode and Javascript
  26. woocommerce 3.2.1 not sending order notification emails
  27. WordPress takes too much time (100 seconds) to load – Front end and back end
  28. WordPress on AWS with ELB
  29. Saving changes in wp_editor
  30. Executing my function once on a specific time
  31. Set Post Format if find a string in title or post content
  32. Display data on Word Press site posts and pages from mysql table
  33. Notepad sticky plugin
  34. Output array into one table cell
  35. WooCommerce Custom Product to checkout
  36. How to periodically scrape and cache strings from remote txt files. – My First Plugin
  37. How to stop or remove an action being called inside a function of an extended class
  38. Automatically add attributes to woocommerce product?
  39. WP Post Template – Templates in own folder
  40. Apple push notification doesn’t work
  41. Avoid class name collision when using third party libraries in plugins?
  42. Adding an Options Page to a Plugin
  43. How do I “get the next 10 posts after post_id == x”?
  44. wordpress plugin is not activating from widget
  45. How to access data in wordpress database externally using php
  46. How make a php script run only with wp-cron
  47. How to add equivalent of php include to one page (as plugin?)
  48. Theme my Login plugin, how to update fields
  49. Edit Yoast SEO breadcrumbs output [closed]
  50. CSS from textarea in options page to frontend what to do
  51. How to simultaneously access the same MySQL database in the main column and sidebar of WordPress?
  52. Adding a slider captcha to the comment system
  53. Date calculations from 2 custom fields
  54. How do I pass a post ID to the page URL?
  55. How to sanitize uploaded file filename from a plugin?
  56. Using WP Category Lists Plugin to Dynamically Display Category (PHP)
  57. How to put JQuery/Ajax inside shortcode?
  58. Plugins Page invisible / white
  59. Error with Image Slide plug-in/ s3slider in WP
  60. How would I go about creating a user ranked post popularity page?
  61. WordPress: PHP code rendering in the wrong place
  62. New to wordpress, Question about editing PHP
  63. wordpress site | All-in-one-cufon IE Issue
  64. WordPress Shortcode to get URL Parameters $_GET[‘name’] redirects for no reason at all
  65. Redirection of users away from wp-admin (but not administrators)
  66. Using a custom plugin to capture input data via Ajax and PHP
  67. Query all customers/users and check for duplicate information
  68. WordPress function not being called from jQuery method
  69. wp_set_auth_cookie causes 403 error in the wooCommerce checkout
  70. Set and access global variable
  71. Easiest way to add dropdown to a page
  72. Using meta_query to get date type values from post_meta table WordPress
  73. Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
  74. How to enable specific plugin only based around shop manager role?
  75. Redirecting a buddyboss profile tab to a different tab if not subscribed to a specific membership
  76. How to get the element ID from new menu list that added with add_filter()?
  77. Override Plugin Script Fucnction in WordPress
  78. How can I add hyperlink in WP_Error message?
  79. code is working properly in Core PHP but writing coding in WordPress
  80. Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
  81. wp_get_post_terms is difference obj model than the one in rest api response
  82. Add a CSS class based on categroy id to archive pages
  83. Changing “elapsed time” to “time remaining” on MP3-jPlayer audio player with CSS or PHP changes
  84. How to fetch products with the price in a page on woocommerce using a form or live search with php
  85. WpDataTables – View Image Directory
  86. Most efficient way to use classes to create admin pages using Settings API
  87. CMB2 toolkit: Compare 2 Dates and validate the Time
  88. Image upload and download from front-end
  89. WooCommerce: Building a page with user input which is used to query order status and external API and return a result
  90. WordPress WPforms customization
  91. PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback Error without any function name
  92. Preg Match All doesn’t Allow echo first character for WordPress Taxonomy Tags
  93. Adding a new field to the address field type in gravity forms
  94. Shrink down register_settings on Settings API
  95. Show admin notice on incorrect value on form field
  96. add image crop function like in wp customizer
  97. Parse error: syntax error, unexpected ‘new’ (T_NEW) in /misc/41/000/204/381/9/user/web/ragami.net/wp-settings.php on line 219
  98. Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
  99. Looking for a way that will collect visitors emails before letting them view the blog posts [closed]
  100. wp_remote_get() returns 403 while file_get_contents() does not
Categories plugins Tags account, email-verification, php, plugins
Why custom taxomony not showing when create a post?
Delete Users without a First and Last Name

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress