• Resolved edeb

    (@edeb)


    Hello there,

    I’m trying to apply your filters and change things like priority and other attributes. It doesn’t work unfortunately. Here is my code.

    add_action( 'init', 'modify_listing_fields');
    function modify_listing_fields(){
    	add_filter( 'submit_job_form_fields', 'featured_image' );
    	add_filter( 'submit_job_form_fields', 'gallery_images' );
    }
    function featured_image( $fields ){
    	$fields[ 'job' ][ 'featured_image' ] = array(
    		'label'       => __( 'Cover Image', 'listify' ),
    		'type'        => 'file',
    		'required'    => false,
    		'placeholder' => '',
    		'priority'    => 2,
    		'ajax'        => true,
    		'allowed_mime_types' => array(
    			'jpg'  => 'image/jpeg',
    			'jpeg' => 'image/jpeg',
    			'gif'  => 'image/gif',
    			'png'  => 'image/png'
    		)
    	);
    	return $fields;
    }
    function gallery_images( $fields ){
    	$fields[ 'job' ][ 'gallery_images' ] = array(
    		'label'       => __( 'Gallery Images', 'listify' ),
    		'type'        => 'file',
    		'multiple'    => true,
    		'required'    => false,
    		'placeholder' => '',
    		'priority'    => 3,
    		'ajax'        => true,
    		'allowed_mime_types' => array(
    			'jpg'  => 'image/jpeg',
    			'jpeg' => 'image/jpeg',
    			'gif'  => 'image/gif',
    			'png'  => 'image/png'
    		)
    	);
    	return $fields;
    }

    I have to say that these 2 custom fields have been added to my theme which is Listify and I’m actually using a child theme, for this reason I’m trying to overriding the hook priority using ‘init’.

    Debug is silent.

    Any suggestion?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Please follow documentation on adding custom fields (you can use this to customize existing ones as well) or use the field editor addon:
    https://wpjobmanager.com/document/editing-job-submission-fields/

    You don’t need to set the action under init, or set it twice with filter, it should be simply this:

    add_filter( 'submit_job_form_fields', 'smyles_custom_submit_form_fields' );
    
    function smyles_custom_submit_form_fields( $fields ){
    	$fields[ 'job' ][ 'featured_image' ] = array(
    		'label'       => __( 'Cover Image', 'listify' ),
    		'type'        => 'file',
    		'required'    => false,
    		'placeholder' => '',
    		'priority'    => 2,
    		'ajax'        => true,
    		'allowed_mime_types' => array(
    			'jpg'  => 'image/jpeg',
    			'jpeg' => 'image/jpeg',
    			'gif'  => 'image/gif',
    			'png'  => 'image/png'
    		)
    	);
    
    	$fields[ 'job' ][ 'gallery_images' ] = array(
    		'label'       => __( 'Gallery Images', 'listify' ),
    		'type'        => 'file',
    		'multiple'    => true,
    		'required'    => false,
    		'placeholder' => '',
    		'priority'    => 3,
    		'ajax'        => true,
    		'allowed_mime_types' => array(
    			'jpg'  => 'image/jpeg',
    			'jpeg' => 'image/jpeg',
    			'gif'  => 'image/gif',
    			'png'  => 'image/png'
    		)
    	);
    
    	return $fields;
    }

    With that said, if you only want to change the priority, just set only that value, you don’t need to set all values:

    add_filter( 'submit_job_form_fields', 'smyles_custom_submit_form_fields' );
    
    function smyles_custom_submit_form_fields( $fields ){
    
    	$fields[ 'job' ][ 'featured_image' ]['priority'] = 2;
            $fields[ 'job' ][ 'gallery_images' ]['priority'] = 3;
    
    	return $fields;
    }

    My reply above too is specifically for the frontend of the site, to modify the admin section follow those same steps but check the tutorial link for the filter and format to use in admin area

    Thread Starter edeb

    (@edeb)

    Ok @tripflex. That did the trick! I didn’t considered the priority about the fieldset thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Filters not working’ is closed to new replies.