Forum Replies Created

Viewing 11 replies - 16 through 26 (of 26 total)
  • Thread Starter davidrevo

    (@davidrevo)

    Just checked the database, I think the data is already saved as postmeta, but the custom field is not hooked up when initializing fields.

    Thread Starter davidrevo

    (@davidrevo)

    Following the wiki for job manager, I added the code below. But it still didn’t pre popup the existing data when I’m doing the update.

    // Add your own function to filter the fields
    add_filter( 'submit_resume_form_fields', 'custom_submit_resume_form_fields' );
    
    // This is your function which takes the fields, modifies them, and returns them
    function custom_submit_resume_form_fields( $fields ) {
    
        // Candidate Name
        $fields['resume_fields']['candidate_name']['label'] = "Candidate name";
    
        // Email Address
        $fields['resume_fields']['candidate_email']['label'] = "Email address";
    
        // Candidate Location
        $fields['resume_fields']['candidate_location']['placeholder'] = 'e.g. "Chadstone, VIC", "Sydney"';
    
        // Add new fields to store the job info of job application
        $fields['resume_fields']['job_listing_ID'] = array(
            'label'       => __( 'Job Listing ID', 'job_manager' ),
            'type'        => 'text',
            'required'    => true,
            'placeholder' => 'The job listing ID e.g. 1023',
            'priority'    => 13
            );
    
        // And return the modified fields
        return $fields;
    }
    
    add_action( 'resume_manager_update_resume_data', 'frontend_add_job_title_field_save', 10, 2 );
    
    function frontend_add_job_title_field_save( $resume_id, $values ) {
        update_post_meta( $resume_id, '_job_apply_job_id', $values['resume_fields']['job_listing_ID'] );
    }
    Thread Starter davidrevo

    (@davidrevo)

    Thanks for your detailed explanation, Mike. That’s easy to understand. Basically, adding custom functions to existing filter is the way to solve out breaking the original code. I will give it a try. This info really helps a lot. Thank you.

    Thread Starter davidrevo

    (@davidrevo)

    Hi Mike,

    One example would be adding a “job region” field ajax search, I changed both some code in “ajax-filter.min.js” (in assets/js/ folder) and “class-wp-job-manager-ajax.php” (in include/ folder). To do this, one more field is added to the ajax search in order to get a concise search based on our scenario.

    The code snippet of the customization is below with changes in bold:

    <——– class-wp-job-manager-ajax.php ———–>

    $result            = array();
    $search_location   = sanitize_text_field( stripslashes( $_POST['search_location'] ) );
    $search_keywords   = sanitize_text_field( stripslashes( $_POST['search_keywords'] ) );
    <strong>$search_regions     = isset( $_POST['search_regions'] ) ? $_POST['search_regions'] : '';</strong>
    $search_categories = isset( $_POST['search_categories'] ) ? $_POST['search_categories'] : '';
    $filter_job_types  = isset( $_POST['filter_job_type'] ) ? array_filter( array_map( 'sanitize_title', (array) $_POST['filter_job_type'] ) ) : null;
    
    if ( is_array( $search_categories ) ) {
    	$search_categories = array_filter( array_map( 'sanitize_text_field', array_map( 'stripslashes', $search_categories ) ) );
    } else {
    	$search_categories = array_filter( array( sanitize_text_field( stripslashes( $search_categories ) ) ) );
    }
    
    <strong>if ( is_array( $search_regions ) ) {
    	$search_regions = array_filter( array_map( 'sanitize_text_field', array_map( 'stripslashes', $search_regions ) ) );
    } else {
    	$search_regions = array_filter( array( sanitize_text_field( stripslashes( $search_regions ) ) ) );
    }	</strong>	
    
    $args = array(
    	'search_location'   => $search_location,
    	'search_keywords'   => $search_keywords,
    	<strong>'search_regions'  	=> $search_regions,</strong>
    	'search_categories' => $search_categories,
    	'job_types'         => is_null( $filter_job_types ) ? '' : $filter_job_types + array( 0 ),
    	'orderby'           => sanitize_text_field( $_POST['orderby'] ),
    	'order'             => sanitize_text_field( $_POST['order'] ),
    	'offset'            => ( absint( $_POST['page'] ) - 1 ) * absint( $_POST['per_page'] ),
    	'posts_per_page'    => absint( $_POST['per_page'] )
    );

    <—————— ajax-filter.min.js ——————->

    jQuery(document).ready(function(a){var b;a(".job_listings").on("update_results",function(c,d,e){b&&b.abort();var f="",g=a(this),h=g.find(".job_filters"),i=g.find(".showing_jobs"),j=g.find(".job_listings"),k=g.data("per_page"),l=g.data("orderby"),m=g.data("order");if(e?a(".load_more_jobs",g).addClass("loading"):(a(j).addClass("loading"),a("li.job_listing",j).css("visibility","hidden")),g.data("show_filters")){var n=[];a(':input[name="filter_job_type[]"]:checked, :input[name="filter_job_type[]"][type="hidden"]',h).each(function(){n.push(a(this).val())});var o=h.find(":input[name^=search_categories], :input[name^=search_categories]").map(function(){return a(this).val()}).get();var z=h.find(":input[name^=search_regions], :input[name^=search_regions]").map(function(){return a(this).val()}).get(),p="",q="",r=h.find(":input[name=search_keywords]"),s=h.find(":input[name=search_location]");r.val()!==r.attr("placeholder")&&(p=r.val()),s.val()!==s.attr("placeholder")&&(q=s.val()),f={action:"job_manager_get_listings",search_keywords:p,search_location:q,search_categories:o,search_regions:z,filter_job_type:n,per_page:k,orderby:l,order:m,page:d,form_data:h.serialize()}}else f={action:"job_manager_get_listings",search_categories:g.data("categories").split(","),search_regions:g.data("regions").split(","),search_keywords:g.data("keywords"),search_location:g.data("location"),per_page:k,orderby:l,order:m,page:d};b=a.ajax({type:"POST",url:job_manager_ajax_filters.ajax_url,data:f,success:function(b){if(b)try{b.indexOf("<!--WPJM-->")>=0&&(b=b.split("<!--WPJM-->")[1]),b.indexOf("<!--WPJM_END-->")>=0&&(b=b.split("<!--WPJM_END-->")[0]);var c=a.parseJSON(b);c.showing?a(i).show().html("").append("<span>"+c.showing+"</span>"+c.showing_links):a(i).hide(),c.html&&(e?a(j).append(c.html):a(j).html(c.html)),c.found_jobs&&c.max_num_pages!==d?a(".load_more_jobs",g).show().data("page",d):a(".load_more_jobs",g).hide(),a(j).removeClass("loading"),a(".load_more_jobs",g).removeClass("loading"),a("li.job_listing",j).css("visibility","visible")}catch(f){}}})}),a("#search_keywords, #search_location, .job_types input, #search_categories, #search_regions").change(function(){var b=a(this).closest("div.job_listings");b.trigger("update_results",[1,!1])}).change(),a(".job_filters").on("click",".reset",function(){var b=a(this).closest("div.job_listings"),c=a(this).closest("form");return c.find(":input[name=search_keywords]").val(""),c.find(":input[name=search_location]").val(""),c.find(":input[name^=search_categories]").val(0),c.find(":input[name^=search_regions]").val(0),a(':input[name="filter_job_type[]"]',c).attr("checked","checked"),b.trigger("reset"),b.trigger("update_results",[1,!1]),!1}),a(".load_more_jobs").click(function(){var b=a(this).closest("div.job_listings"),c=a(this).data("page");return c=c?parseInt(c):1,a(this).data("page",c+1),b.trigger("update_results",[c+1,!0]),!1})});

    Thanks for help, Mike

    Thread Starter davidrevo

    (@davidrevo)

    Thanks for the coming number based pagination, Mike. Appreciate it a lot!

    Thread Starter davidrevo

    (@davidrevo)

    Thanks for the reply, Mike. Good to know the actual function of pagination.php. Do you mean that there is no way to do pagination under your plugin? It is very hard for customers to navigate around jobs without a pagination feature. Another confuse is that how could I do some customization of other plugins files rather than those in “templates” folder. Your plugin is really good. We r starting to use your resume manager plugin as well.

    Thread Starter davidrevo

    (@davidrevo)

    I’ve tried to use the key for all comparisons at first sight. It does not work. Then I change to use label afterwards, others are working fine instead of job_deadline. ?? very weird behavior

    Thread Starter davidrevo

    (@davidrevo)

    No Problem, Mike. Here it is:

    add_filter( 'manage_edit-job_listing_sortable_columns', 'my_sortable_job_listing_column' );
    function my_sortable_job_listing_column( $columns ) {
        $columns["job_position"] = __( "Position", 'wp-job-manager' );
        $columns["job_posted"] = __( "Posted", 'wp-job-manager' );
        $columns["job_expires"] = __( "Expires", 'wp-job-manager' );
        $columns['job_deadline'] = __( 'Closing Date', 'job_manager_app_deadline' );
        //To make a column 'un-sortable' remove it from the array
        //unset($columns['date']);
    
        return $columns;
    }
    
    add_action( 'pre_get_posts', 'my_job_listing_orderby' );
    function my_job_listing_orderby( $query ) {
        if( ! is_admin() )
            return;
    
        $orderby = $query->get( 'orderby');
    
        if( __( "Position", 'wp-job-manager' ) == $orderby ) {
            $query->set('orderby','title');
        }
    
        if ( __( "Posted", 'wp-job-manager' ) == $orderby ) {
            $query->set('orderby','date');
        }
    
        if ( __( "Expires", 'wp-job-manager' ) == $orderby ) {
            $query->set('meta_key','_job_expires');
            $query->set('orderby','meta_value_num');
        }    
    
        if ( __( 'Closing Date', 'job_manager_app_deadline' ) == $orderby ) {
            $query->set('meta_key','_application_deadline');
            $query->set('orderby','meta_value_num');
        }
    }
    Thread Starter davidrevo

    (@davidrevo)

    Hi Mike,

    “meta_value_num” still seems do not work.

    “_application_deadline” meta field comes from “Application Deadline Plugin” and it is new added field. The code for its addition is below:

    <em>	public function columns( $columns ) {
    		$new_columns = array();
    
    		foreach ( $columns as $key => $value ) {
    			if ( $key == 'job_expires' )
    				$new_columns['job_deadline'] = __( 'Closing Date', 'job_manager_app_deadline' );
    
    			$new_columns[ $key ] = $value;
    		}
    
    		return $new_columns;
    	}
    
    	public function custom_columns( $column ) {
    		global $post;
    
    		if ( $column == 'job_deadline' ) {
    			if ( ! ( $deadline = get_post_meta( $post->ID, '_application_deadline', true ) ) )
    				echo '<span class="na">&ndash;</span>';
    			else
    				echo date_i18n( __( 'M j, Y', 'job_manager' ), strtotime( $deadline ) );
    		}
    	}
    </em>

    Thanks.
    Wei

    Thread Starter davidrevo

    (@davidrevo)

    Hi Mike,

    Thanks for this informative and helpful resource. I’ve figured out most of my puzzles. Basically, for the standard fields in job manager, I used $query->set(‘orderby’,’title’); to filter those fields. It is successful.

    However, for “_application_deadline” post meta, the little sorting triangle appears, but the sorting does not work as expected. The code snippet below:

    if ( __( ‘Closing Date’, ‘job_manager_app_deadline’ ) == $orderby ) {
    $query->set(‘meta_key’,’_application_deadline’);
    $query->set(‘orderby’,’meta_value’);
    }

    Could you help me further regarding this? Thanks a lot!!!

    Thread Starter davidrevo

    (@davidrevo)

    Hi Mikejolley, thanks for your reply. Yeah, actually I test one individual record, and just insert those missing meta data into wp_postmeta table.It works and is populated on the job page. There are some meta data fields which may be required to show the job on page. Thanks very much

Viewing 11 replies - 16 through 26 (of 26 total)