There is a syntax error in your conditional:
current_user_can(‘administrator’)
The input value is wrapped in ‘ ’
, which should be wrapped in ' '
instead. Right now, because ‘administrator’
is neither a role nor capability, the above will always return a false value, therefore
if(!current_user_can(‘administrator’))
will always return true
, which will restrict the mime type for everyone, including administrators. The correct form will be :
if( !current_user_can('administrator') ) {
//CODE HERE
}
Related Posts:
- How to register images uploaded via FTP in media library?
- Convert all images to PNG on file upload
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false
- Upload multiple files in randomly generated folder using wp_upload_bits
- Convert all uploaded PNG files to PNG-8 format
- Restrict File Type Uploads by User on Wordress via functions.php
- Save the outputted image into the Media Library, with a different filename and extension
- Generate and upload screenshot as featured image for user-submitted post
- Uploading media with the REST API
- wp_set_object_terms and arrays
- How to get the original price of the product in woocommerce?
- How to redirect users to custom lostpassword page?
- How to use WordPress (PHP) functions in AngularJS partials files?
- Can I write ‘RewriteCond’ using ‘functions.php’?
- How to add 2 posts under another post? Formatting should be intact
- Logout and redirect using the WP Menu
- Check if current page is wp-admin
- Using PHP to toggle stylesheet and header image, set in cookie
- Insert all post IDs in new database table
- Nested shortCode functions in the functions.php file
- Show only IF not Google bot [closed]
- How to speed up admin-ajax.php in wordpress
- My Own layout in WooCommerce pages [closed]
- Woocommerce – remove product from category
- How do I publish only one page to production after making changes on staging?
- Using Multiple Submit buttons to trigger customised php functions
- How to get specific image in media library with php
- get current product name in functions.php
- How to style options page in dashboard?
- Change the WP Video Shortcode Output
- How to retrieve current wordpress profile page URL?
- Why ajax doesn’t work on certain wordpress hooks?
- Print last modified date only on posts
- Upload multiple images to a Woocomerce product
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- Exclude category
- WordPress automatically adds links to uploaded images
- Security for data obtained from the database
- What exactly do this function declared into functions.php file of a WP theme?
- Make Current/Active Page Number a Link (WP_LINK_PAGES)
- How to make modifications only to certain elements of an HTML string on the server-side?
- Custom Pagination is Broken
- Sidebar not appearing in footer, but it appears everywhere else!
- Co-Authors Plus: How do I get all authors with a query?
- Why i can’t get custom fields value or post ID via Ajax?
- List post by title length
- How to reference PHP in Javascript
- Why is my max_upload_filesize being limited to 2M? [duplicate]
- Fallback image URL if no featured image exists via a shortcode function
- how to enqueque code in a php file from functions.php
- Deactivate a plugin on wp version
- making php value numeric
- the_post_thumbnail issues
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Uses for function: wp_update_user
- WP insert post Redirect after function has executed
- How to assign page id with array in page_scheduled_event
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- Cannot find the php_ini configuration file to find my error log to see why my code is not working
- How to Send Pingbacks for all Posts in WordPress?
- HTML comment cause issue in functions.php script root
- Programmatically add a product to the cart and set price to zero when buying from certain category
- I want to show cart items number if any or nothing, simple CART text
- Exclude category from function – PHP
- Sudden Upload HTTP errors, PHP uploads and memory limits are already to high to my taste. Anything else?
- Hide a specific category title from displaying on site
- WordPress Ajax filter: Create two loops for different output styles?
- Handling form actions in WordPress
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- How to call a function from functions.php with ajax?
- Set user status to absent on WordPress
- Shortcode’s output to use as other shortcode’s parameter
- Displaying POST content with HTML tags and all
- PHP script to redirect traffic based on website accessed
- How to remove title tag with this filter
- Why transition_post_type hook is called twice for the same post?
- Showing wordpress latest post thumbnails in slider with auto increment
- media_handle_upload fails with gravity form submitted image
- My function echos only “array”
- Notify admin (by email) if post added with specific tag
- Retrieving specific images from Media Library
- Can’t put a hyperlink on Featured Post’s Image
- Limit Taxonomy Parents
- WordPress HTML Helper
- List sibling pages widget, exclude current page
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- Permission error on plugin save
- Display default WordPress login/registration form into a modal window
- How to add button to top of theme customizer?
- File Upload with Server in safe_mode
- Pull GET parameter from URL in functions.php
- Adding Gravity Form With if(is_page) Is Not Working
- Send foreach $_post method to contact form 7 [closed]
- Options.php loop won’t show!
- Alternative to php echo within code
- Add multiple HTML attributes to an Elementor button
- /page/2/ redirect to 404
- get_post_meta returns on side but it doesn’t return on bottom of admin page