From 32a22e5fd62e86edd1032d502aa98d7e326f32fa Mon Sep 17 00:00:00 2001 From: Viktor Miller Date: Sat, 17 Jan 2026 21:20:16 +0900 Subject: [PATCH] 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 --- includes/class-ddhh-job-manager.php | 3 +++ includes/class-roles.php | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/includes/class-ddhh-job-manager.php b/includes/class-ddhh-job-manager.php index e53b31b..77bf2f8 100644 --- a/includes/class-ddhh-job-manager.php +++ b/includes/class-ddhh-job-manager.php @@ -50,6 +50,9 @@ class DDHH_JM_Job_Manager { // Initialize post types 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 add_action( 'acf/init', array( 'DDHH_JM_ACF_Fields', 'register_fields' ) ); diff --git a/includes/class-roles.php b/includes/class-roles.php index f494a5d..39bed82 100644 --- a/includes/class-roles.php +++ b/includes/class-roles.php @@ -28,6 +28,7 @@ class DDHH_JM_Roles { // Job offer capabilities (own only) 'edit_job_offers' => true, + 'edit_published_job_offers' => true, 'delete_job_offers' => 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 * Called on plugin deactivation */ 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 job_offer capabilities from administrator