92

Add the following to wp-config.php: define( 'FS_METHOD', 'direct' ); Let me know how it works for you.


32

Because I had cut and pasted define(’FS_METHOD’,’direct’); from the web, the incorrect quote characters were pasted into the file. should be define('FS_METHOD', 'direct'); The incorrect quote character also changed the encoding of the file somehow. If anyone has deeper knowledge of this issue please let me know in the comments.


29

This is a read-write permission error. Fix this by changing the "wp-content" folder's permissions to 755. If this doesn't work checked the wp-config.php file and if it's not already defined, add define('WP_TEMP_DIR', ABSPATH . 'wp-content/');


24

Do not point the URL to admin.php, use admin-post.php instead: '<a href="' . admin_url( 'admin-post.php?action=print.csv' ) . '">' In your plugin register a callback for that action: add_action( 'admin_post_print.csv', 'print_csv' ); function print_csv() { if ( ! current_user_can( 'manage_options' ) ) return; header('Content-Type: ...


21

This means that WordPress is having limited permission for making changes in the folder that it was installed. In-order to fix this, all that you need to do is provide necessary permissions for the same. Run the following Command in your Terminal / Putty / Commandline Prompt after connecting to your Server via SSH: sudo chown -R apache:apache /var/www/...


20

Special thanks to user42826. According to the codex: If WordPress is hosted behind a reverse proxy that provides SSL, but is hosted itself without SSL, these options will initially send any requests into an infinite redirect loop. To avoid this, you may configure WordPress to recognize the HTTP_X_FORWARDED_PROTO header (assuming you have properly ...


17

I found the problem. In settings > media the folder for uploads was actually pointing to a different path. Once I redirected it to wp-content/uploads it all worked.


14

Method 1: Remove the upload_files capability from the respective roles. e.g. removing it from author: $role = get_role( 'author' ); $role->remove_cap( 'upload_files' ); This is saved to the database so it should only happen once, not on every page load. Removing it from the editor role should be the same albeit with the obvious modification. Removing ...


12

Here's what Codex has to say on restricting database user privileges: For normal WordPress operations, such as posting blog posts, uploading media files, posting comments, creating new WordPress users and installing WordPress plugins, the MySQL database user only needs data read and data write privileges to the MySQL database; SELECT, INSERT, UPDATE and ...


11

You have to give the capability a true or false, like this: add_role('user', 'User', array( 'read' => true )); To fix it, first remove the role and than re-add it again. remove_role('user'); add_role('user', 'User', array('read' => true)); http://codex.wordpress.org/Function_Reference/add_role


10

Your site has likely been hacked. My site had the Darkleech infection, which injected some malicious code into wp-includes/nav-menu.php, causing .htaccess to reset to 444 on any page load. I'd recommend you install the Sucuri plugin and let it restore any files that have been corrupted. Assuming your site was hacked, use their Post-Hack tab to reset plugins,...


9

Don't let the action die, just do a redirect (to wherever you'd like): function wpse_92155_before_delete_post() { wp_redirect(admin_url('edit.php')); exit(); } // function wpse_92155_before_delete_post add_action('before_delete_post', 'wpse_92155_before_delete_post', 1);


9

Okay here we go. It is a bug in WordPress itself. I have already shortly explained the issue in my question, so either have a look at it or check out the ticket linked above for more details. Until the issue is properly resolved I propose this dirty, dirty hack. It is based off the idea that as soon as another sub-menu that is accessible is added ...


9

The issue was because I wasn't generating and sending a nonce value with the request. In order to generate a nonce value. Localize the value of a wp_create_nonce('wp_rest') function call. wp_localize_script('application', 'api', array( 'root' => esc_url_raw(rest_url()), 'nonce' => wp_create_nonce('wp_rest') )); This will then be accessible to ...


9

So, after several attempts... it is a problem (or a feature) of the WPML multilanguage plugin. To start with, I have set up correctly the user permissions, as @WebElaine mentioned. Just in case something was not configures properly. More information on the following articles: Permissions to wp-content folder in Windows Server 2012 https://www.chillies.co.za/...


8

If you add the following to your wp-config.php file it will force WordPress to use the 'direct' filesystem method: define( 'FS_METHOD', 'direct' );


7

The only prerequisite for current_user_can() is an existing wp_get_current_user(). The latter is defined in pluggable.php, so you can use it after plugins_loaded. The _doing_it_wrong() call you are citing in your question is wrong for itself. My guess is that you took that from BuddyPress or bbPress. Both are running into a recursion if they don't wait that ...


6

Even though it is totally correct to have the ownership as root:apache with permissions 775, and httpd to run as apache, Wordpress does not like this. It wants the owner to be apache, as per wp-admin/includes/file.php: // Attempt to determine the file owner of the WordPress files, and that of newly created files $wp_file_owner = $temp_file_owner = ...


6

The problem, as the error description indicates, is permissions. Based on that tutorial, nginx is running under the www-data user, but WP folders are owned by deployer. If you change the ownership of your $WP_ROOT to www-data:www-data, you will find that you can update your WP. I'm not amazing at security, so there may be a better way, but this one will ...


5

There's a reason why add_role() has the $capabilities as 3rd parameter. First some insights on what happens, when you use the function. It calls WP_Roles->add_role() - the class method The method then does a check if the role already exists. If yes, it aborts. The next step is, that it adds the role to WP_Roles->roles[] array with the display_name (...


5

The PHP files in the wp-includes directory will do nothing when accessed directly. They are designed to be include()'d in an existing PHP script, such as on the front-end or in the dashboard. Your Options -Indexes entry in the .htaccess file simply prevents a list of the files in a directory when no index.php is present. It's good practice to use this on a ...


5

I would use the hook before_delete_post as the last layer of protection against deletion (using @tf's solution, and which is the correct Answer). And first remove the "Delete" options from sight. The following hides the Bulk Actions and the Empty Trash button, and removes the Delete Permanently row action. With this code: add_action( 'admin_head-...


5

Here's the code from wp-admin/includes/file.php: if ( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){ if ( !$context ) $context = WP_CONTENT_DIR; // If the directory doesn't exist (wp-content/languages) then use the parent directory // as we'll create it. if ( WP_LANG_DIR == $context &&...


5

If you moved your page from one host to another - check if your Upload path is correct to your new host (and not a leftover from previous host) Navigate to: http://YOURDOMAIN/wp-admin/options.php Find the field for "upload_path" and cross check.


5

Thanks @kaiser but not need to go through your solution I found a easy one and I'll share here for newbie likes me. If you're working on a WP Network site then the steps are: At the top, hover over My Sites and then click Network Admin. At the left, hover over Settings and then click Network Settings. Scroll to the bottom of the page and change the Max ...


5

There are three ways you could do this: 1. Upload all into the Media Library The most tiresome way, IMHO, is to upload all the images you got via the media library. 2. Use a plugin You can use plugins like Add From Server to import your images easily to the Media Library 3. WP-CLI Easiest way once you got WP-CLI installed. Run wp media import to import ...


5

I've had the same problem, and in my case it was the Wordpress cronjob. I was calling the wp-cron.php as a root cron job, and this script also generates the monthly upload folder. If you call wp-cron.php via cronjob you need to do this as the web server user (or i.e. in Plesk the site user and group psacln). The owner of the created monthly folder is always ...


4

WordPress and Apache WordPress needs to be able to use Apache. By default Apache runs on Ubunutu as user www-data. And ... www-data is also a member of the group www-data So when you try to do a Git Pull then every file will have the wrong permissions as it's expecting the owner to be able to run things on Apache. If you do a CHOWN to make everything ...


4

The admin_menu action will hide the ACF menu, in this example for not-admins. And admin_head will block the access if the URL is accessed directly. E.g.: http://example.com/wp-admin/edit.php?post_type=acf and http://example.com/wp-admin/edit.php?post_type=acf&page=acf-settings add_action( 'admin_menu', 'wpse_59032_remove_acf_menu', 9999 ); add_action( '...


4

If you did want to lock things down.... a normal wordpress site will usually only require the database user to have SELECT, INSERT, UPDATE and DELETE. If you want to use the automatic update feature it will also require CREATE and ALTER. Some plugins may require other permissions but most won't.


Only top voted, non community-wiki answers of a minimum length are eligible