• I’m trying to work with a simple plugin that I’ve coded myself.

    It works when I upload it via the WP Plugin Dashboard. But, once I do this, I’m unable to edit the file when I open it via FTP (I get an “open for write: permission denied error”).

    However, if I upload the file via FTP into the plugins folder, I am able to edit it. This leads me to believe that uploading the file via the WP Plugin Dashboard is changing the file permission (I’m unable to change it via FTP though my host claims I have full permissions).

    I haven’t been able to figure out how to activate the plugin once uploaded via FTP …I did try the script in my functions.php file:

    function activate_plugin_wc() {
        $active_plugins = get_option( 'active_plugins' );
        array_push($active_plugins, 'Software_Request_Form/software_request_form.php'); /* Here just replace  plugin directory and plugin file*/
        update_option( 'active_plugins', $active_plugins );
    }
    add_action( 'init', 'activate_plugin_wc' );

    If anyone has insight into this issue it would be much appreciated.

    Thanks so much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    The user PHP and WP runs as becomes the file owner when you add plugins through the WP backend. When you try to open a file for editing outside of WP, you are a different user which does not have write permission. Typically only the file owner has write permission. There are a couple ways around this. One is to use the built in WP Plugin Editor. The other is to use FTP to download the file to your local computer, make the changes you want locally, then upload back to the server. When you upload back, the file should inherit its parent folder’s properties, thus WP still maintains ownership and write permissions.

    While adding the extra steps of downloading/uploading is sort of a pain, it does allow you to keep backups and edit using your favorite code editor. Ideally, this editor would automatically keep backup copies. Backups may not seem that important. They’re not until your site crashes due to the latest edit and you can’t figure out what went wrong. Then there’s nothing in the world better than that backup.

    Thread Starter mattjacobnyc

    (@mattjacobnyc)

    Thanks so much @bcworkz

    Previously, I was using Filezilla, right-clicking the file to navigate to view/edit file, editing the file, then saving it to update via FTP as well.

    I tried how you mentioned as well (downloading via FTP and then uploading via FTP with Filezilla), but unfortunately got the same ‘open for write: permission denied’ error.

    It seems (at least with Filezilla) that these methods are not inheriting the properties of the file.

    I like your idea about editing via the WP Dashboard editor.

    I’m stuck though in terms of how I get the plugin to show up in the dashboard. The plugin activates and works in all other respects, but for some reason it doesn’t show up in the Dashboard with the plugins.

    Do you know (or know a reference to docs) if there’s certain code (or know a reference to docs) that should go in the file to make it show up in the dashboard?

    Thanks!!

    Moderator bcworkz

    (@bcworkz)

    I suppose there’s any number of ways for a plugin to be hidden. All that matters is if it shows up in the drop down list on the plugin editor screen. If not, the editor option isn’t going to work without digging into code to learn how the plugin is hidden.

    If you have write permission errors on the file you edited after uploading back to the server, use Filezilla to adjust the permissions. Usually 0644 is correct, but you could try 0664. 0666 will solve the problem because anyone can then edit the file, a big security issue if left that way. If you have terminal access, you could change file ownership to that which PHP runs as, usually www-data or apache.

    Dion

    (@diondesigns)

    This is being caused by one of two things:

    1. You signed up for “WordPress hosting” from a substandard provider
    2. Your webserver has an archaic configuration

    If you have contacted your hosting company and they weren’t able to help, there isn’t anything you can do about (1) other than to move to a better provider.

    You can fix (2) by running your webserver in a FastCGI configuration, preferably with PHP-FPM. This applies to a VPS, dedicated server, or localhost setup on a Linux-based system (Mac included). Windows-based systems are immune to this problem unless the system owner did something really stupid.

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

The topic ‘Custom Coded Plugin – File Permission Changed When Uploaded via Plugin Dashboard’ is closed to new replies.