Is there a way to set the user Role based on email domain

With this code, you will check during the registration the users email and attach the roles you want to: <?php add_action( ‘user_register’, ‘wp234_set_role_by_email’ ); function wp234_set_role_by_email( $user_id ){ $user = get_user_by( ‘id’, $user_id ); $domain = substr( strrchr( $user->data->user_email, “@” ), 1 ); //Get Domain $contributor_domains = array( ‘gmail.com’ ); if( in_array( $domain, $contributor_domains ) … Read more

500 Internal Server Error after Register dialog, but with successful registration

Internal Server errors are usually thrown when there’s an error somewhere in the code. You did the right thing searching the logs, but depending on your hosting configuration not all errors can be written there. I like using WordPress’s own logging facility. Here’s what you need to do: Stick the following lines in your wp-config.php … Read more

How to reload the role specific registration form on validation errors?

You can either user session or cookies to setup the user for the desired role e.g: /** * register_roles_with_cookies */ class register_roles_with_cookies { function __construct($args = array()){ //create a hidden field for role and extra fields needed add_action(‘register_form’,array($this,’add_hidden_role_field’)); //validate add_action(‘register_post’,array($this,’my_user_fields_validation’),10,3); //save the role add_action(‘user_register’, array($this,’update_role’)); } public function setCookie($name,$val,$time = false){ if(false === $time) $time … Read more

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