How to limit user registration to a specific set of domains?

You can do it easily by writing a code inside your theme’s functions.php file. here is the code: function is_valid_email_domain($login, $email, $errors ){ $valid_email_domains = array(“gmail.com”,”yahoo.com”);// whitelist email domain lists $valid = false; foreach( $valid_email_domains as $d ){ $d_length = strlen( $d ); $current_email_domain = strtolower( substr( $email, -($d_length), $d_length)); if( $current_email_domain == strtolower($d) ){ … Read more

Add Custom User Capabilities Before or After the Custom User Role has Been Added?

There’s a reason why add_role() has the $capabilities as 3rd parameter. First some insights on what happens, when you use the function. It calls WP_Roles->add_role() – the class method The method then does a check if the role already exists. If yes, it aborts. The next step is, that it adds the role to WP_Roles->roles[] … Read more

Different back-end language for different users?

We could try to filter the WPLANG option locale (see e.g. this approach from the related list here on the right by @brasofilo, that’s based on this one by @toscho ): /** * Override locale settings for the current (non-admin) user */ is_admin() && add_filter( ‘locale’, function( $locale ) { // Modify locale for non-admins … Read more

How to limit users to one comment per post

// Check if user has previously commented the post. global $current_user, $post; if ( ! is_user_logged_in() ) { // Show the comment form if the user is not logged in. comment_form(); } else { // The user is logged in… // Get the comments for the logged in user. $usercomment = get_comments( array ( ‘user_id’ … Read more

Disallowing Users of a Custom Role from Deleting or Adding Administrators?

Hi @NetConstructor: I think this is what you need. Note that I didn’t include the full setup of your ‘website_owner’ role, just the addition of a new capability called ‘manage_administrators’. Also, I only attempted to remove the “Delete” link from any users that don’t have the ‘manage_administrators’ capability (which you’ll need to add to the … Read more

How to do get_users() with multiple meta_keys

As it mentions in the Codex page for get_users, it works the same as a WP_Query meta_query, see that page for full arguments list and examples. $args = array( ‘meta_query’ => array( array( ‘key’ => ‘some_key’, ‘value’ => ‘foo’, ‘compare’ => ‘=’ ), array( ‘key’ => ‘another_key’, ‘value’ => array( ‘bar’, ‘baz’ ) ‘compare’ => … Read more

Network not displaying all sites and users

When WordPress builds such a list, it runs a check against the function wp_is_large_network(). It sets a limit of 10000 for users and sites, and when you hit that limit, expensive database operations aren’t executed anymore. There are two filters with the same name, so you can change the limit. Example: add_filter( ‘wp_is_large_network’, function( $state, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)