Forums

Role Scoper
[resolved] When Publish custom post add post author to group (3 posts)

  1. darkenpl
    Member
    Posted 1 year ago #

    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);

    http://wordpress.org/extend/plugins/role-scoper/

  2. kevinB
    Member
    Plugin Author

    Posted 1 year ago #

    ScoperAdminLib::add_group_user( $group_id, $user_id );
  3. darkenpl
    Member
    Posted 1 year ago #

    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic