• Resolved hazratnoor

    (@hazratnoor)


    I am using the wp-job-manager plugin on my WordPress website. This is actually a theme and I want my users to be able to keep/store some default values in fields when they are adding a new job. I have researched for a while and I couldn’t find any satisfying results. I think this might be possible using an add-on or something else. I need some help in this scenario.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You can do it quite easily with this https://plugins.smyl.es/wp-job-manager-field-editor/

    or there are some prefill snippets here https://wpjobmanager.com/customization-snippets/

    Thread Starter hazratnoor

    (@hazratnoor)

    The prefill snippets will be going directly to my theme’s functions.php? Or into another file?

    Thread Starter hazratnoor

    (@hazratnoor)

    I have tried the following snippet at the end of my theme’s functions.php file and it doesn’t change anything in the admin side.

    add_filter('submit_job_form_fields', 'bk_prefill_jobs_location');
    	function bk_prefill_jobs_location( $fields ) {
    	  $fields['job']['job_location']['value'] = 'My Custom City Name';
    	  return $fields;
    	}

    Under the Job Listings sidebar item (which appears after installing WP Job Manager Plugin), when a user will click on the Add New sub-menu item for adding a new job, I want this code snippet to prefill the location field for the user. Is this possible with this snippet or am I misunderstanding the purpose of customization through code snippets?

    Try using the Code Snippets plugin–I’ve had snippets not work when placed in the functions.php file, but work through the Code Snippets plugin.

    I also second @dubaidogfish’s mention of WP Job Manager Field Editor, which is incredibly helpful.

    Plugin Contributor Richard Archambault

    (@richardmtl)

    @hazratnoor Do you still need help?

    Thread Starter hazratnoor

    (@hazratnoor)

    The following solution works for me:

    function save_job_meta( $post_id, $post, $update ) {
    
        $post_type = get_post_type($post_id);
        $meta = get_post_meta( $post_id );
    	//var_dump( $post );
        // If this isn't a 'job_listing' post, don't update it.
        if ( "job_listing" != $post_type ) return;
            
    	$location = $meta['_job_location'][0];
    	$brand = $meta['_business_brand'][0];
        
        if($update){    
    	    update_user_meta( get_current_user_id(), '_job_location', $meta['_job_location'][0] );
    	    update_user_meta( get_current_user_id(), '_business_brand', $meta['_business_brand'][0] );
    	    update_user_meta( get_current_user_id(), '_company_website', $meta['_company_website'][0] );
    	    update_user_meta( get_current_user_id(), '_company_name', $meta['_company_name'][0] );
    	    update_user_meta( get_current_user_id(), '_company_tagline', $meta['_company_tagline'][0] );
    	}
    }
    add_action( 'save_post', 'save_job_meta', 10, 3 );
    Thread Starter hazratnoor

    (@hazratnoor)

    My problem is resolved now. The above solution can be used to show those mentioned fields including business brand, company website, job location, company name and company tagline as prefilled for an existing user. If the user has already posted a job in the past, these fields will be shown prefilled.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to store default values in add new job fields?’ is closed to new replies.