@@ -9,7 +9,142 @@ image: "https://comforthrm.com/assets/images/seo.png"
99card : " article"
1010
1111---
12- # Code Samples
1312
13+ # Code Samples for ComfortJobApp & ComfortJobAppPro
14+
15+ ## ComfortJobApp Plugin
16+
17+ ### 1. Apply Job Form Hooks
18+
19+ Add custom content before and after the job application form using action hooks.
20+
21+ ``` php
22+ do_action( 'comfortjobapp_apply_job_form_before', $form_id, $job_id, $job, $fields );
23+ ?>
24+ <form method =" post" id =" comfortjobapp-apply-form" enctype =" multipart/form-data" class =" cbx_form_wrapper" >
25+ <?php do_action( 'comfortjobapp_apply_job_form_start', $form_id, $job_id, $job, $fields ); ?>
26+ <input type =" hidden" name =" job_id" value =" <?php echo intval( $job['id'] ); ?>" />
27+ <?php do_action( 'comfortjobapp_apply_job_form_end', $form_id, $job_id, $job, $fields ); ?>
28+ </form >
29+ <?php
30+ do_action( 'comfortjobapp_apply_job_form_after', $form_id, $job_id, $job, $fields );
31+ ```
32+
33+ ### 2. Get Application Forms
34+
35+ Retrieve a list of application forms for the current user.
36+
37+ ```
38+ <?php
39+ $forms = comfortjobapp_get_application_forms([
40+ 'limit' => 10,
41+ 'page' => 1,
42+ 'created_by' => get_current_user_id(),
43+ ]);
44+
45+ foreach ( $forms as $form ) {
46+ echo esc_html( $form['title'] );
47+ }
48+ ```
49+ ### 3. Enqueue Public Scripts
50+ Enqueue public-facing scripts and pass JS translations.
51+
52+ ```
53+ <?php
54+ $forms = comfortjobapp_get_application_forms([
55+ 'limit' => 10,
56+ 'page' => 1,
57+ 'created_by' => get_current_user_id(),
58+ ]);
59+
60+ foreach ( $forms as $form ) {
61+ echo esc_html( $form['title'] );
62+ }
63+ ```
64+
65+ ### 4. Delete an Application
66+ Delete an application by ID.
67+ ```
68+ <?php
69+ comfortjobapp_delete_application( $application_id );
70+ ```
71+
72+ ### 5. Delete a Form
73+
74+ ``` php
75+ // Delete a form by ID (ComfortJobApp)
76+ $result = comfortjobapp_delete_form($form_id);
77+ ```
78+
79+ ## ComfortJobAppPro Plugin
80+
81+ ### 1. Add Employer Dashboard Menu
82+ Add a custom menu to the employer dashboard.
83+
84+ ```
85+ <?php
86+ add_filter( 'comfortjobapp_employer_dashboard_menus', function( $menus ) {
87+ $menus['custom_menu'] = [
88+ 'title' => esc_html__( 'My Custom Menu', 'comfortjobapppro' ),
89+ 'type' => 'callback',
90+ 'callback' => 'custom_menu_callback',
91+ ];
92+ return $menus;
93+ } );
94+
95+ function custom_menu_callback() {
96+ echo '<h2>' . esc_html__( 'Welcome to My Custom Menu', 'comfortjobapppro' ) . '</h2>';
97+ }
98+ ```
99+
100+ ### 2. Filter Application Steps
101+ Modify the application steps for the job application process.
102+
103+ ```
104+ <?php
105+ add_filter( 'comfortjobapp_steps', function( $steps ) {
106+ $steps['custom_step'] = esc_html__( 'Custom Step', 'comfortjobapppro' );
107+ return $steps;
108+ } );
109+ ```
110+
111+ ### 3. Custom Email Notification
112+ Customize the email notification sent to applicants.
113+
114+ ```
115+ <?php
116+ add_filter( 'comfortjobapp_email_template', function( $template, $application ) {
117+ $template['subject'] = esc_html__( 'Thank you for applying!', 'comfortjobapppro' );
118+ $template['body'] = sprintf(
119+ esc_html__( 'Dear %s, thank you for applying for the %s position.', 'comfortjobapppro' ),
120+ $application['candidate_name'],
121+ $application['job_title']
122+ );
123+ return $template;
124+ }, 10, 2 );
125+ ```
126+
127+ ### 4. Export Application Data
128+ Export application data in JSON format.
129+
130+ ```
131+ <?php
132+ add_action( 'admin_post_export_applications', function() {
133+ $applications = ComfortJobApp::query()->get()->toArray();
134+ $json_data = json_encode( $applications, JSON_PRETTY_PRINT );
135+
136+ header( 'Content-Type: application/json' );
137+ header( 'Content-Disposition: attachment; filename="applications.json"' );
138+ echo $json_data;
139+ exit;
140+ } );
141+
142+ ```
143+
144+ For more details, see the plugin documentation or explore the helpers in:
145+
146+ - [ ` ComfortJobAppHelpers ` ]
147+ - [ ` comfortjobapp-functions.php ` ]
148+ - [ ` ComfortJobAppProMisc ` ]
14149
15150
0 commit comments