fix(07-01): allow providers to edit published job offers

Added edit_published_job_offers capability to ddhh_provider role and created upgrade_roles function to automatically add this capability to existing provider accounts. Providers can now edit their published job offers from the dashboard.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-17 21:20:16 +09:00
parent 7f2c5fa6a6
commit 32a22e5fd6
2 changed files with 21 additions and 0 deletions

View File

@@ -50,6 +50,9 @@ class DDHH_JM_Job_Manager {
// Initialize post types // Initialize post types
add_action( 'init', array( 'DDHH_JM_Post_Types', 'register' ) ); add_action( 'init', array( 'DDHH_JM_Post_Types', 'register' ) );
// Upgrade roles with any new capabilities
add_action( 'init', array( 'DDHH_JM_Roles', 'upgrade_roles' ) );
// Initialize ACF fields // Initialize ACF fields
add_action( 'acf/init', array( 'DDHH_JM_ACF_Fields', 'register_fields' ) ); add_action( 'acf/init', array( 'DDHH_JM_ACF_Fields', 'register_fields' ) );

View File

@@ -28,6 +28,7 @@ class DDHH_JM_Roles {
// Job offer capabilities (own only) // Job offer capabilities (own only)
'edit_job_offers' => true, 'edit_job_offers' => true,
'edit_published_job_offers' => true,
'delete_job_offers' => true, 'delete_job_offers' => true,
'upload_files' => true, 'upload_files' => true,
@@ -70,11 +71,28 @@ class DDHH_JM_Roles {
} }
} }
/**
* Upgrade existing roles with new capabilities
* Called on plugin init to ensure all capabilities are present
*/
public static function upgrade_roles() {
$provider_role = get_role( 'ddhh_provider' );
if ( $provider_role && ! $provider_role->has_cap( 'edit_published_job_offers' ) ) {
$provider_role->add_cap( 'edit_published_job_offers' );
}
}
/** /**
* Remove custom roles * Remove custom roles
* Called on plugin deactivation * Called on plugin deactivation
*/ */
public static function remove_roles() { public static function remove_roles() {
// Remove provider role capabilities before removing role
$provider_role = get_role( 'ddhh_provider' );
if ( $provider_role ) {
$provider_role->remove_cap( 'edit_published_job_offers' );
}
remove_role( 'ddhh_provider' ); remove_role( 'ddhh_provider' );
// Remove job_offer capabilities from administrator // Remove job_offer capabilities from administrator