Code Snippet Overview:
This WCFM code snippet will Restrict store owners to upload the filetypes that you establish. This snippet is great when the admin of the Marketplace wants to have the same file type of image in the product pages. When you install the WCFM plugin of WCLovers the default General settings allow the user to upload the same filetypes that WordPress allows when he or she creates a product.
Result
Now, after you have added this WCFM code snippet the seller won’t be able to upload your defined filetype, in this case is .PNG:
Code Snippet
/*WCFM Code Snippet to restrict the upload certain filetypes*/
add_filter('upload_mimes','restrict_mime');
function restrict_mime($mimes) {
$mimes = array(
'png' => 'application/octet-stream',
);
return $mimes;
}
Implementation
- Copy WCFM code snippet by clicking on the right upper corner of the code.
- Download the Code Snippets plugin.
- Click on Add new snippet.
- Paste the code that you have copied in step 1.
Customize according to your needs:
In this example, we are restricting .PNG files, but, suppose you need to restrict another type of files. You just need to change png
in this line:
'png' => 'application/octet-stream',
In case you need to restrict more than one type of file, the syntaxis will be:
'jpg|jpeg|jpe'
=> 'application/octet-stream',
Another post:
- Make mandatory the first name and last name – WCFM registration
- Easy to add Vendor category on WCFM Dashboard – Show on the store page
- WCFM Snippet Send Vendor Bank Details to the Customer
- QUIT STEPS IN THE STORE WIZARD SETUP OF WCFM MARKETPLACE
- WooCommerce Subscription with Downloads also add shortcode to the pricing plan
- How to animate shape divider in elementor
- 5 Reasons Why You Should Not Use Nulled WordPress Themes and Plugins
- Debug WordPress, the right way
- Most common HTTP error codes explained and how do you troubleshoot them
- How to change logo color when scrolling in Elementor
- Create animated gradient background with elementor
- Introducing Elementor Blocks for Gutenberg
Check out our categories: Android Update, Elementor, flutter, Guide, Game, Plugin, Theme, webmaster, SEO, Woocommerce, WCFM