Change user role when post approve

You can attach code to change role when post status is changing from “pending” to “published” see documentation: http://codex.wordpress.org/Post_Status_Transitions Then, if user has role “contributor” you can change this to “author”:

    add_action( 'pending_to_publish'. 'my_function', 10, 1 );
    function my_function( $post )
    {
        $wp_user_object = new WP_User( $post->post_author );
        if ( in_array('contributor', $wp_user_object->roles ) ) {
            $wp_user_object->remove_role( 'contributor' );
            $wp_user_object->add_role( 'author' );
        }
    }

error code: 521