Wpjb_Model_Job class reference
Job Object is the object you will be (probalby) using in job board template files most often, it contains information about particular job and provides interface to access related information (for example Company which posted a job).
The Job Object class is Wpjb_Model_Job, the class file is at wpjobboard/application/libraries/Model/Job.php
Public properties
-
id
(int) The Job id -
employer_id
(int) The Employer/Company id of company which posted this job -
job_title
(string) The job title -
job_slug
(string) The unique, URL friendly job identifier -
job_description
(string) Full job descrption -
job_created_at
(string) The date when job was posted, in format “YYYY-MM-DD” -
job_modified_at
(string) The date when job was last modified, in format “YYYY-MM-DD” -
job_expires_at
(string) The job expiration date, in format “YYYY-MM-DD” -
job_country
(int) Country ISO 3166-1 Numeric code -
job_state
(string) The Job state (as a state inside a country) -
job_zip_code
(string) The Job zip code -
job_city
(string) The Job city/location -
company_name
(string) Company name -
company_url
(string) Absolute company URL -
company_email
(string) Email address to which job applications will be sent -
is_approved
(int) Either 0 or 1, only jobs with is_approved equal to 1 are displayed in the frontend -
is_active
(int) Either 0 or 1, this is a job state (active or inactive) set by administrator -
is_filled
(int) Either 0 or 1, if 1 then job is marked as filled -
is_featured
(int) Either 0 or 1, if 1 job is displayed as featured -
applications
(int) Number of job applications sent -
tag
(object) Object containig information about categories and job types (usage below) -
meta
(object) Object containing information about fields added using Custom Fields (usage below)
Public Methods
save()
Saves (inserts or updates) Job in database.
Parameters None
Returns (int) Job unique ID
delete()
Deletes Job from database along with all job files and meta data.
Parameters None
Returns NULL
url()
Returns absolute Job URL (works only for jobs that are saved in DB)
Parameters None
Returns (string) Absolute Job URL (starting with http://)
Usage Examples
Loading job saved in database and displaying its title and url
$job = new Wpjb_Model_Job(5); echo $job->job_title . "<br/>"; echo $job->url();
Loading job saved in database, changing title and saving changes in DB
$job = new Wpjb_Model_Job(15); $job->job_title = "Job title updated!"; $job->save();
Using tags to display job types and categories
$job = new Wpjb_Model_Job(7); // check if job is assigned o any categories if(!empty($job->tag->category)) { foreach($job->tag->category as $item) { echo $item->title . " - " . $item->url() . "<br/>"; } } // check if job has assigned any job types if(!empty($job->tag->type)) { foreach($job->tag->type as $item) { echo $item->title . " - " . $item->url() . "<br/>"; } }
Using meta values to display job description format
$job = new Wpjb_Model_Job(9); echo $job->meta->job_description_format->value(); // value() works when meta field can have only one value // if meta field can have more than one value (for example // checkbox or multi select) you should use values() instead // it will return array of values echo join(", ", $job->meta->job_descritpion_format->values());