Hi
I made (with some help from the internet) a little code to change role of author who post was published by someone else.
How I can it change to work with users groups aka When custom post is published by someone else, author of post is added to particular group.
function update_roles($pce_newstatus, $pce_oldstatus, $pce_object)
{
global $wpdb;
$pce_newstatus = 'pending';
$pce_oldstatus = 'publish';
// Get the author
$author = get_userdata($pce_object->post_author);
// Do the checks to see if they have the roles and if not update them.
if (user_can($author->ID, 'subscriber'))
{
// Remove role
$author->remove_role( 'subscriber' );
// Add role
$author->add_role( 'contributor' );
}
}
add_filter('transition_post_status', 'update_roles','',3);