Set user role, if an specific role created an user

You can use user_register action, which is invoked after registering a new user. To add or remove roles/caps, the WP_User class provides methods: add_cap(), add_role() remove_cap(), remove_role() Your code might look like this: add_action( ‘user_register’, ‘se385135_user_register’ ); function se385135_user_register( $user_id ) { $user = wp_get_current_user(); if ( !isset( $user->ID ) || $user->ID == 0 ) … Read more

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

On action, change user role

Couple of things perhaps spring to mind – when using add_action you’ll need to provide how many of the arguments you’re planning on using. Default 1. You’re not using request info so get rid of that. Second bit geodir_get_current_posttype() link Read through how the function works and make sure it makes sense and would work … Read more

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