WP Job Openings
  • Introduction
  • Getting Started
    • Installation
    • Shortcodes
  • Pro Pack for Wp Job Openings
    • WP Job Openings Pro
    • Installation
  • Overview
    • Job Openings Overview
  • Settings
    • General
    • Appearance
    • Job Specifications
    • Form
    • Notifications
  • Settings - Wp Job Openings Pro
    • Appearance
    • Job Specifications
    • Form
    • Notifications
    • Shortcodes
    • Advanced
  • Job Listing
    • Add New Openings
    • Job Listings
    • Job Listings – Admin
    • Customizing templates of your Job Listings
  • Applications
    • Application Listings
    • View Application
    • Spam Protection
  • EXPORT (PRO)
    • Export Applications
  • Widgets
    • Recent Jobs Widget
    • Job Overview Dashboard Widget
  • User Access Control Addon
    • User Access Control Add-on
    • Installation
    • Settings
    • Tutorial
  • JOB ALERTS ADDON
    • Job Alerts Add-on
      • How it works
      • Job Alerts Block
      • Job Alerts Emails
    • Installation
    • Settings
      • Appearance
      • Shortcode Generator
      • Email Settings
  • Other Add-ons
    • Docs Viewer Add-On for WP Job Openings
    • Auto Delete Applications – Add-on for WP Job Openings
  • Developers
    • Hooks
      • Actions
        • Application Actions
        • Application Details
        • Application Form
        • Application Submission
        • Email
        • Job Expiry
        • Job Listing
        • Job Specifications
        • Job Status
        • Settings
        • Widget - Recent Jobs
      • Filters
        • Application Form
        • Email
        • Job Filter
        • Job Specifications
        • Layout
        • Meta Data
        • Navigation
        • Post Type
        • Query
        • Settings
        • Shortcode
        • Structured Data
    • Code Snippets
      • Archive page title
      • Custom Application Status
      • Custom Permalink - Slug Issue
      • Limit the file size
      • Modify or Remove the Structured Data
      • Remove 'All' prefix from the filter
      • Remove job application form
      • Sort by title
    • WP-CLI
      • Managing Form Builder Options
    • CRM Integration
  • FAQ
  • Sources and Credits
Powered by GitBook
On this page

Was this helpful?

  1. Developers
  2. Code Snippets

Limit the file size

If you need to limit the upload file size you can use the below code snippet.

In the code snippet, we are limiting the file size to 1 MB. Please change the value to your preferred choice.

function awsm_application_upload_size_limit( $size ) {
	if ( is_singular( 'awsm_job_openings' ) ) {
		$size = 1 * 1024 * 1024; // 1 MB
	}
	return $size;
}
add_filter( 'upload_size_limit', 'awsm_application_upload_size_limit' );

function awsm_job_application_submitting() {
	global $awsm_response;
	if ( count( $awsm_response['error'] ) === 0 && isset( $_FILES ) && count( $_FILES ) > 0 ) {
		$error = false;
		foreach ( $_FILES as $file ) {
			$limit = 1 * 1024 * 1024; // 1 MB
			if ( $file['size'] > $limit ) {
				$error = true;
			}
		}
		if ( $error ) {
			$awsm_response['error'][] = 'The file you have selected is too large';
		}
	}
}
add_action( 'awsm_job_application_submitting', 'awsm_job_application_submitting' );

PreviousCustom Permalink - Slug IssueNextModify or Remove the Structured Data

Last updated 4 years ago

Was this helpful?

How to Easily Add Custom Code to Your WordPress Websites