How to programmatically add a user to a role?

You can do that like this :

$my_user = new WP_User( $user_id );
$my_user->set_role( "editor" );

Leave a Comment

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