Add a second role when registering programmatically

You could use the register_new_user hook which fires after the registration is complete. e.g. function add_role_to_new_user( $user_id ) { $new_user = get_userdata( $user_id ); if ( $new_user ) { $new_user->add_role( ‘a_second_role’ ); } } add_filter( ‘register_new_user’, ‘add_role_to_new_user’ ); This will – I think – fire for all new users, including new administrators added in the … Read more

Automatically register users with comments

There are a number of functions you can use: register_new_user wp_create_user wp_insert_user The first function being the most simple to use and the last function gives you many more options – it depends what you want to do. You can create the new account when the comment is posted using the comment_post hook. You will … Read more

Perform multiple actions after wp_insert_user()

Note that wp_set_auth_cookie() will set cookies (using setcookie()) which means there must be no output (HTML, spaces, empty lines, etc.) sent to the browser yet, or otherwise, the cookies will not be set or updated. And I said that because by the time you call wp_insert_user(), there has actually been an output sent to the … Read more

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