Allow contributors to create page (but not publish)

How would you go about this?

I see this is an old question and that you found a solution with an existing plugin. However, since this is a development StackExchange, it’s probably better if there’s an answer that explains how to accomplish the stated goals without the need for a third-party plugin.

Written Answer

WordPress stores capabilities in the database. Therefore, what we want is a plugin that will add the edit_pages capability to the contributor role upon plugin activation. For completeness, the plugin should remove the capability upon deactivation.

Coded Answer

/**
 * Plugin Name: WPSE 230940
 */

//* Add activation hook
register_activation_hook( __FILE__ ,  'wpse_230940_activation' );    
function wpse_230940_activation() {
  //* Add edit_pages capability to contributors
  $contributor = get_role( 'contributor' );
  $contributor->add_cap( 'edit_pages' );
}

//* Add deactivation hook
register_deactivation_hook( __FILE__ , 'wpse_230940_deactivation' );
function wpse_230940_deactivation() {
  //* Remove edit_pages capability from contributors
  $contributor = get_role( 'contributor' );
  $contributor->remove_cap( 'edit_pages' );
}