• Resolved kirksmacdonald

    (@kirksmacdonald)


    Hi guys need a bit of help

    on the post a job form it is split into two files top sections is called from

    class-wp-job-manager-form-submit-job.php

    and this serves the form job title to company details/logo

    the second file serves from company details/description to Established date/year

    in this file jobhunt-wpjmc-functions.php

    All the data from class-wp-job-manager-form-submit-job.php top section is auto-populated if the employer has posted before here is the code for it to work.

    
    		// And user meta to save time in future.
    		if ( is_user_logged_in() ) {
    			update_user_meta( get_current_user_id(), '_company_name', isset( $values['company']['company_name'] ) ? $values['company']['company_name'] : '' );
    			update_user_meta( get_current_user_id(), '_company_website', isset( $values['company']['company_website'] ) ? $values['company']['company_website'] : '' );
    			update_user_meta( get_current_user_id(), '_company_tagline', isset( $values['company']['company_tagline'] ) ? $values['company']['company_tagline'] : '' );
    			update_user_meta( get_current_user_id(), '_company_twitter', isset( $values['company']['company_twitter'] ) ? $values['company']['company_twitter'] : '' );
    			update_user_meta( get_current_user_id(), '_company_video', isset( $values['company']['company_video'] ) ? $values['company']['company_video'] : '' );
    		}
    
    		do_action( 'job_manager_update_job_data', $this->job_id, $values );
    	}

    and section

    	/**
    	 * Initializes the fields used in the form.
    	 */
    	public function init_fields() {
    		if ( $this->fields ) {
    			return;
    		}
    
    		$allowed_application_method = get_option( 'job_manager_allowed_application_method', '' );
    		switch ( $allowed_application_method ) {
    			case 'email':
    				$application_method_label       = __( 'Application email', 'wp-job-manager' );
    				$application_method_placeholder = __( 'you@example.com', 'wp-job-manager' );
    				$application_method_sanitizer   = 'email';
    				break;
    			case 'url':
    				$application_method_label       = __( 'Application URL', 'wp-job-manager' );
    				$application_method_placeholder = __( 'https://', 'wp-job-manager' );
    				$application_method_sanitizer   = 'url';
    				break;
    			default:
    				$application_method_label       = __( 'Application email/URL', 'wp-job-manager' );
    				$application_method_placeholder = __( 'Enter an email address or website URL', 'wp-job-manager' );
    				$application_method_sanitizer   = 'url_or_email';
    				break;
    		}
    
    		if ( job_manager_multi_job_type() ) {
    			$job_type = 'term-multiselect';
    		} else {
    			$job_type = 'term-select';
    		}
    		$this->fields = apply_filters(
    			'submit_job_form_fields',
    			array(
    				'job'     => array(
    					'job_title'       => array(
    						'label'       => __( 'Job Title', 'wp-job-manager' ),
    						'type'        => 'text',
    						'required'    => true,
    						'placeholder' => '',
    						'priority'    => 1,
    					),
    					'job_location'    => array(
    						'label'       => __( 'Location', 'wp-job-manager' ),
    						'description' => __( 'Leave this blank if the location is not important', 'wp-job-manager' ),
    						'type'        => 'text',
    						'required'    => false,
    						'placeholder' => __( 'e.g. "London"', 'wp-job-manager' ),
    						'priority'    => 2,
    					),
    					'job_type'        => array(
    						'label'       => __( 'Job type', 'wp-job-manager' ),
    						'type'        => $job_type,
    						'required'    => true,
    						'placeholder' => __( 'Choose job type…', 'wp-job-manager' ),
    						'priority'    => 3,
    						'default'     => 'full-time',
    						'taxonomy'    => 'job_listing_type',
    					),
    					'job_category'    => array(
    						'label'       => __( 'Job category', 'wp-job-manager' ),
    						'type'        => 'term-multiselect',
    						'required'    => true,
    						'placeholder' => '',
    						'priority'    => 4,
    						'default'     => '',
    						'taxonomy'    => 'job_listing_category',
    					),
    					'job_description' => array(
    						'label'    => __( 'Description', 'wp-job-manager' ),
    						'type'     => 'wp-editor',
    						'required' => true,
    						'priority' => 5,
    					),
    					'application'     => array(
    						'label'       => $application_method_label,
    						'type'        => 'text',
    						'sanitizer'   => $application_method_sanitizer,
    						'required'    => true,
    						'placeholder' => $application_method_placeholder,
    						'priority'    => 6,
    					),
    				),
    				'company' => array(
    					'company_name'    => array(
    						'label'       => __( 'Company name', 'wp-job-manager' ),
    						'type'        => 'text',
    						'required'    => true,
    						'placeholder' => __( 'Enter the name of the company', 'wp-job-manager' ),
    						'priority'    => 1,
    					),
    					'company_website' => array(
    						'label'       => __( 'Website', 'wp-job-manager' ),
    						'type'        => 'text',
    						'sanitizer'   => 'url',
    						'required'    => false,
    						'placeholder' => __( 'http://', 'wp-job-manager' ),
    						'priority'    => 2,
    					),
    					'company_tagline' => array(
    						'label'       => __( 'Tagline', 'wp-job-manager' ),
    						'type'        => 'text',
    						'required'    => false,
    						'placeholder' => __( 'Briefly describe your company', 'wp-job-manager' ),
    						'maxlength'   => 64,
    						'priority'    => 3,
    					),
    					'company_video'   => array(
    						'label'       => __( 'Video', 'wp-job-manager' ),
    						'type'        => 'text',
    						'sanitizer'   => 'url',
    						'required'    => false,
    						'placeholder' => __( 'A link to a video about your company', 'wp-job-manager' ),
    						'priority'    => 4,
    					),
    					'company_twitter' => array(
    						'label'       => __( 'Twitter username', 'wp-job-manager' ),
    						'type'        => 'text',
    						'required'    => false,
    						'placeholder' => __( '@yourcompany', 'wp-job-manager' ),
    						'priority'    => 5,
    					),
    					'company_logo'    => array(
    						'label'              => __( 'Logo', 'wp-job-manager' ),
    						'type'               => 'file',
    						'required'           => false,
    						'placeholder'        => '',
    						'priority'           => 6,
    						'ajax'               => true,
    						'multiple'           => false,
    						'allowed_mime_types' => array(
    							'jpg'  => 'image/jpeg',
    							'jpeg' => 'image/jpeg',
    							'gif'  => 'image/gif',
    							'png'  => 'image/png',
    						),
    					),
    				),
    			)
    		);
    
    		if ( ! get_option( 'job_manager_enable_categories' ) || 0 === intval( wp_count_terms( 'job_listing_category' ) ) ) {
    			unset( $this->fields['job']['job_category'] );
    		}
    		if ( ! get_option( 'job_manager_enable_types' ) || 0 === intval( wp_count_terms( 'job_listing_type' ) ) ) {
    			unset( $this->fields['job']['job_type'] );
    		}
    	}

    and this bit of coding works the company details for this section works when pre-populating which good

    But the bottom half of the form is served from file jobhunt-wpjmc-functions.php

    and that code for that bit to work

    /**
     * Add company fields in post job form
     */
    if ( ! function_exists( 'jobhunt_submit_job_form_fields' ) ) {
        function jobhunt_submit_job_form_fields() {
            $fields = array(
                'company_description' => array(
                    'label'       => esc_html__( 'Description', 'jobhunt' ),
                    'type'        => 'wp-editor',
                    'required'    => false,
                    'priority'    => 1,
                ),
                'company_team_size' => array(
                    'label'       => esc_html__( 'Team size', 'jobhunt' ),
                    'type'        => 'term-select',
                    'required'    => false,
                    'placeholder' => esc_html__( 'Choose Team Size…', 'jobhunt' ),
                    'priority'    => 2,
                    'default'     => '',
                    'taxonomy'    => 'company_team_size',
                ),
                'company_category' => array(
                    'label'       => esc_html__( 'Category', 'jobhunt' ),
                    'type'        => 'term-multiselect',
                    'required'    => false,
                    'placeholder' => '',
                    'priority'    => 3,
                    'default'     => '',
                    'taxonomy'    => 'company_category',
                ),
                'company_location' => array(
                    'label'       => esc_html__( 'Location', 'jobhunt' ),
                    'description' => esc_html__( 'Leave this blank if the location is not important', 'jobhunt' ),
                    'type'        => 'text',
                    'required'    => false,
                    'placeholder' => esc_html__( 'e.g. "London"', 'jobhunt' ),
                    'priority'    => 4,
                ),
                'company_email' => array(
                    'label'       => esc_html__( 'Email', 'jobhunt' ),
                    'type'        => 'text',
                    'required'    => false,
                    'placeholder' => esc_html__( 'you@yourdomain.com', 'jobhunt' ),
                    'priority'    => 5,
                ),
                'company_phone' => array(
                    'label'       => esc_html__( 'Phone', 'jobhunt' ),
                    'type'        => 'text',
                    'required'    => false,
                    'placeholder' => esc_html__( 'phone Number', 'jobhunt' ),
                    'priority'    => 6,
                ),
                'company_facebook' => array(
                    'label'       => esc_html__( 'Facebook', 'jobhunt' ),
                    'type'        => 'text',
                    'required'    => false,
                    'placeholder' => esc_html__( 'Facebook page url', 'jobhunt' ),
                    'priority'    => 7,
                ),
                'company_googleplus' => array(
                    'label'       => esc_html__( 'Google+', 'jobhunt' ),
                    'type'        => 'text',
                    'required'    => false,
                    'placeholder' => esc_html__( 'Google+ url', 'jobhunt' ),
                    'priority'    => 8,
                ),
                'company_linkedin' => array(
                    'label'       => esc_html__( 'LinkedIn', 'jobhunt' ),
                    'type'        => 'text',
                    'required'    => false,
                    'placeholder' => esc_html__( 'LinkedIn url', 'jobhunt' ),
                    'priority'    => 9,
                ),
                'company_since' => array(
                    'label'       => esc_html__( 'Since', 'jobhunt' ),
                    'type'        => 'date',
                    'required'    => false,
                    'placeholder' => esc_html__( 'Established date/year', 'jobhunt' ),
                    'priority'    => 10,
                )
            );
    

    but there is no section for pre-populating company data

    question one why is the bottom half served from two files surly having it all on the class-wp-job-manager-form-submit-job.php would make things easier

    second question how do i pre poulate the second half of the form with meta data on the jobhunt-wpjmc-functions.php

    It is would be rather annoying if a company would have to keep adding this detail in again about thier company every time they posted a new job especially as they might have multiple posters and as the fields come a blank everytime a new job post for them might alter thier company details by mistake let alone super annoying filling all that company data out on every post.

    Even if it is set in the back end a job poster would automatically type thier company details again as the fields populate blank on the lower half of the form.

    I think they will start to get annoyed with this if they have to do this for every job post

    How to fix this

    Thanks kirk macdonald

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kirksmacdonald

    (@kirksmacdonald)

    ok some more to my findings

    if you preview the posting then edit the posting

    then all of the fields pre-populate even if left blank on the initial job posting

    Plugin Contributor Richard Archambault

    (@richardmtl)

    Hi,

    jobhunt-wpjmc-functions.php is not part of WP Job Manager itself. So it sounds like this is from a theme (most likely) or a 3rd-party plugin. As such, I won’t be able to assist. Best if you ask your theme author for help.

    Plugin Contributor Richard Archambault

    (@richardmtl)

    I’m marking this thread as Resolved as it’s been more than a month since the last reply. If you still need help, please do reply again and mark the thread as Unresolved!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Company details auto populate’ is closed to new replies.