Method to allow users to mark their jobs as

Hi,

In two previous tickets I have notes about a method to allow users to mark their jobs status - as Open, Complete, In progress etc.

To do this we created an extra field called - custom_job_status

Details of the code provided by Hoang is included in this thread: https://premium.wpmudev.org/forums/topic/is-it-possible-to-add-additional-fields-to-the-jobs-create-form

(i also has a topic https://premium.wpmudev.org/forums/topic/how-can-users-mark-a-job-as-no-longer-available - but this was closed and linked to the one mentioned above)

It has got a bit confusing and I have not had a reply in a month on that ticket so I have started this to try and resolve this:

The three remaining issues from that ticket specifically related to marking jobs status are:

1. How can I make the "Open" option on custom_job_status the default selection on the add job form? (this will be something added to the code generating the extra field)

2. HHow can I hide the Job from the public jobs board if the status is anything other than "Open" - ie. If the job status is changed to "Pending", "In Progress" or "Completed" it won't show publicly (similar to how a job does not show publicly if it is marked as a draft.)

3. How can I display the custom_job_status in place of the Status column ("Published" or "Draft") on the table generated by the [jbp-my-job-page] shortcode.

If these issues can be resolved it would be a complete solution.

Many thanks
Chris

  • Hoang Ngo

    Hi @Chris,

    I hope you are well today and I do sorry for the delay :slight_frown:

    1. How can I make the "Open" option on custom_job_status the default selection on the add job form? (this will be something added to the code generating the extra field)

    Can you please try this code for the dropdown?

    $form->select( "custom_job_status", array(
    
    	"attributes" => array( "class" => "form-control"),
    
    	"data"       => get_status_list(),
    	'selected'=>array('skill_1')
    
    ) )

    2. HHow can I hide the Job from the public jobs board if the status is anything other than "Open" - ie. If the job status is changed to "Pending", "In Progress" or "Completed" it won't show publicly (similar to how a job does not show publicly if it is marked as a draft.)

    Please add this code to your theme functions.php or use mu-plugins

    add_filter( 'jbp_job_search_params', 'exclude_expires_job' );
    function exclude_expires_job( $args ) {
    	$jobs = JE_Job_Model::model()->all();
    	foreach ( $jobs as $job ) {
    		if ( $job->is_expired() ) {
    			$args['post__not_in'][] = $job->id;
    		}
    	}
    
    	$meta_query = array(
    		array(
    			'key'     => 'custom_job_status',
    			'value'   => 'skill_1',
    			'compare' => '=',
    		),
    	);
    	if ( ! isset( $args['meta_query'] ) ) {
    		$args['meta_query'] = $meta_query;
    	} else {
    		$args['meta_query'] = array_merge( $args['meta_query'], $meta_query );
    	}
    
    	return $args;
    }

    Please note, this code is include the fix for won't show expired jobs to public too.

    3. How can I display the custom_job_status in place of the Status column ("Published" or "Draft") on the table generated by the [jbp-my-job-page] shortcode.

    Published, Draft is native WordPress. We can register custom status by the function register_post_status. But this will require you to update your code about the custom job status to this(native things), instead of using the _postmeta like now. Currently we already have this dropdown in the admin side. Do you still need to update this?

    Best regards,
    Hoang

  • chris

    Hi Hoang,

    I have updated #1 and #2 on http://twiddlejobs.com/demo/

    This seems to work well. Changing the status will remove it from the board.

    Currently it shows the warning messages (as per thread: https://premium.wpmudev.org/forums/topic/is-it-possible-to-add-additional-fields-to-the-jobs-create-form?replies=31#post-948382) due to the multiple selection on the status field display I think.

    I have left this in place so you can see this.

    #3 - I will wait regarding this requirement until the rest is working without warning. I think by linking the job contact email directly to editing the job will be sufficient to mark the job status to something other than open and hide it from the board.

    My idea here though would be to all users to quickly mark the jobs status from their My Jobs board. To do this they would need to see the Job Status displayed.

    In my view this is a different requirement from marking a post as Published or Draft. This option should definitely still exist alongside any new Job Status selector on that page.

    I think this would make the solution very complete and logical for users.

    I will update on this once the warning messages have been resolved.

    Thanks
    Chris

  • chris

    The warning messages i mentioned in the previous post have been resolved (kindly by Hoang).

    This just leaves the query about whether it is possible to display the new Job Status field on the My Jobs table.

    My idea here though is to allow all users to quickly mark their jobs status from their My Jobs board. To do this they would need to see the Job Status displayed on that page.

    In my view this is a different requirement from marking a post as Published or Draft. This option should definitely still exist alongside any new Job Status selector on that page.

    I think this would make the solution very complete and logical for users to be able to manage jobs they have posted in an efficient way.

    Any suggestions on this would be greatly appreciated.

    Thanks again
    Chris

  • chris

    Hi - Expired jobs are not being hidden when using this code:

    This was suppose to contain a fix for hiding the expired jobs. I now see all expired jobs are still showing on the jobs boards.

    The code used is:

    add_filter( 'jbp_job_search_params', 'exclude_expires_job' );
    function exclude_expires_job( $args ) {
    	$jobs = JE_Job_Model::model()->all();
    	foreach ( $jobs as $job ) {
    		if ( $job->is_expired() ) {
    			$args['post__not_in'][] = $job->id;
    		}
    	}
    
    	$meta_query = array(
    		array(
    			'key'     => 'custom_job_status',
    			'value'   => 'skill_1',
    			'compare' => '=',
    		),
    	);
    	if ( ! isset( $args['meta_query'] ) ) {
    		$args['meta_query'] = $meta_query;
    	} else {
    		$args['meta_query'] = array_merge( $args['meta_query'], $meta_query );
    	}
    
    	return $args;
    }

    Can you please check - Support access is open.

    Thanks
    chris

  • chris

    Please see https://premium.wpmudev.org/forums/topic/how-to-hide-expired-jobs-from-the-jobs-board

    this has an update as follows:

    Hi Patrick and Hoang,

    I have found that the function to exclude expired jobs is directly related to whether the Advanced Search add on is active or not.

    I have tested this on a few different sites and it is always the same - disable Advanced Search and the jobs that have expired or have a custom status other than OPEN will be hidden... enable Advanced search add on and all jobs will show regardless.

    I hope this is helpful to understand the changes needed.

    Thanks
    Chris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.