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:
- how to change the verification url of pie register plugin of wordpress?
- Disable email notification after change of password
- __(): What if I have to pass in a variable?
- Run WP-CLI using PHP
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- Plugin update error message
- How can I make my custom shortcode work in a Custom HTML Widget?
- PHP Deprecated: Non-static method should not be called statically
- Set a User as Author of all ‘New Posts’ posted
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- Post source link plugin – small modification
- Which hook callback has priority if both plugin and theme use the same hook?
- Calling function from within functions.php returns unwanted value
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Check if a class exists within a method
- Escape special characters in image link
- Displaying admin notice dynamically
- Calling a plugin in theme development
- Get total number of comment of the posts written by an author
- force customers to add only single item to card per purchase EDD [closed]
- How to get post URL in the_content filter?
- Write to / remove from default .htaccess file from plugin?
- Auto delete WordPress users according to time
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- Why isn’t admin_notices displaying my text? [Simple Plugin, Beginner]
- Programatically download a plugin
- Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
- How to Use Parameters with a Do_Action Function Within PHP Tags
- Theme my Login plugin, how to update fields
- CSS from textarea in options page to frontend what to do
- How do I pass a post ID to the page URL?
- wp_set_auth_cookie causes 403 error in the wooCommerce checkout
- add image crop function like in wp customizer
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- Bootstrap and Custom CSS in custom plugin are being overwritten by theme
- Customize permalink wordpress category id
- Take input from form and pass it to function using a wp-plugin
- Self-serve ad system like Reddit’s for WordPress? [closed]
- Create a plugin from within WordPress
- Class variables not correct on page
- Load Javascript from Plugin in One Page Only?
- Call plugin with php function
- Warning: Use of undefined constant list_all – assumed ‘list_all’ (this will throw an Error in a future version of PHP)
- How to distinguish if a plugin is not installed or just not active
- JavaScript in a PHP plugin
- Checking the count within a foreach loop
- Is there a function to list all uploaded images? How can I add one?
- A server-side hook failed when committing plugin code to SVN
- Content-Security-Policy Headers are there and showing the correct settings, but still getting a refused connection
- Need to replace Currency Shortforms
- How to delete all categories programatically?
- How to use custom Javascript code inside a plugin?
- How to use printf to output two links?
- speed up pagination for huge database
- Using meta_query in a WP_Query not working for numbers properly
- Building a plugin into a theme
- 2 wordpress site same database
- How to redirect to a page after the form is submitted
- WP Insert Post If user refreshes override new post
- Code for unique user visit count on every page WordPress
- Searching a tab/space delimited text file based upon form criteria and returning a ‘record’ into a word press results page
- How to makes changes on the shop/category/tag pages but not on the product pages in woocommerce?
- How to get current cart values using WC_Shortcodes?
- How to authorize viewing and clicking a function only logged users?
- How to arrange custom posts in the backend/admin by custom taxonomy
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Redirect to a page while maintaining search query parameters without causing an infinite loop
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- the content of the uploads folder gets deleted periodically, how to figure out what causes it?
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- Custom Field used to allow a Free Story; no longer works
- How to send new visitor to a splash page for only one time in wordpress?
- Cron job shedules replace?
- Create a form and have custom menu display based on user answers?
- How to get the total count of Favorite/Favorited authors
- Can i add custom code in Source in specific page, Header from function.php?
- Problem with conditional woocommerce custom checkout field
- GET web api method from a WordPress PHP script
- Adding link on title its in description but not in title see screenshots attached
- Editing Global Variables from Inside Functions
- Save selectlist value (taxonomy) in wp:wp_set_object_terms
- Page doesn’t load
- Posting code inside the post instead of in the template file using shortcode
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- conditional tags for the output of a plugin
- Can’t insert files in other inputs
- How do I output user_registered time in my correct timezone?
- How to fix ‘Call to undefined function do_settings()’ error?
- How to tweak a plugin without preventing it from updating
- Place max_execution_time in plugin [closed]
- Creating a press page for our project
- how to search through plugin in wordpress cimy-user-extra-fields?
- wordpress illegal string offset ‘parameter’ error
- Passing an input variable through a switch statement
- wp_handle_upload – specified file failed upload test
- How to change all the urls of the WordPress site?
- How do I remove the filter from the orders and add custom status in Dokan?
- How to make a Template page to show the information of different things Shop and Product page?
- Split Million WordPress Post’s Into Multiple Database Server
- public custom posts not showing in my wordpress plugin