Automattic / Automattic/WP-Job-Manager

Expiry date set in a frontend form gets overriden by the default value when listing approved.

Open
#1,389 8 comments 0 reactions 0 assignees View on GitHub
[Pri] Low Enhancement
Dominant language
PHP
Stars
899
Forks
369
Avg merge
11h 37m
Merged PRs (30d)
12

Description

Hi all,

The events :
1. a frontend form allows registered people to post a listing. A datepicker field with 'job_expires' name sends the correct value to the preview function which correctly adds and fills the meta '_job_expires' (a simple 'echo' on the preview form can prove it).
2. The listing is approved by an admin and the value of _job_expires is overidden by the default value which was set in backoffice.
3. Workaround :
I added a condition to the ligne ‘delete_post_meta( $job->ID, ‘_job_expires’ );’ in preview_handler function in the class-wp-job-manager-form-submit-job.php file

```
// Reset expiry ...
// only if _job_expires meta is empty
if ( empty($job->_job_expires) ) { delete_post_meta( $job->ID, '_job_expires' ); }
```

Now, the expiry date is kept on approving the listing.

Website : https://www.okupy.me/
The form : https://www.okupy.me/deposer-une-annonce/

WP : 4.9.4
WP-Job-Manager : 1.30.1
Win10 - Chrome / FF / Vivaldi

Contributor guide

Open the contributing guide

Research direction

Start in class-wp-job-manager-form-submit-job.php, at preview_handler and the delete_post_meta call for _job_expires. Reproduce the frontend submission and approval flow, comparing the meta value before preview and after approval. Done means an explicitly submitted expiry date is retained while the configured default still applies when no expiry was submitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.