On my web sites the contributors (person function contributor) are allowed to submit posts. All their posts are usually not printed routinely (these posts are with pending standing). After approving their first submit, i modify their person function to creator. This can be a guide course of and that i need to make it routinely. So when their first submit will get accepted their person function will get modified routinely from contributor to creator.
I take advantage of a customized submit sort for this posts. It’s referred to as ‘portfolio’.
I used to be attempting to switch this code snippet, however i am unable to make it working. What I’m doing incorrect?
add_action( 'pending_to_publish'. 'my_function', 10, 1 );
perform my_function( $submit )
{
$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( 'creator' );
}
}