views:

22

answers:

1

I've a theme which supports multiple templates, each with a header background image whose color can be set by the site owner via a colorpicker widget in my theme's options panel. This has the effect of opening the background image, recoloring it and resaving it back to the server.

I've had zero issues with this routine until recently when a customer installed the theme on a web host whose default read/write permissions are apparently much more restrictive than the norm. In this case, the user was unable to alter the colors of the template images because of the permissions settings.

I'm looking for a bit of understanding on what the permissions would need to be (assuming I purposefully set them via script) to allow the logged in wordpress user to write to files under my theme's styles directory.

The code I'm using to write to the image file is below...

    $img = imagecreatefromgif("../wp-content/themes/mytheme/styles/".get_option('my_theme')."/image.gif");
    $color = imagecolorallocate($img, $info["red"], $info["green"], $info["blue"]);
    imagecolorset($img, 0, $info["red"], $info["green"], $info["blue"]);
    imagegif($img, $path);
A: 

What I have done in the past (and what I have seen people instruct other to do for autoupdate / wordpress file management) was to chown apache-user.apache-user folder/

This way you give the apache user (that is running apache for instance) access to the wordpress files, keep them at whatever permissions you want (read/write/exec).

Give that a try.

(of course replace apache-user with the proper user, ex: www-data)

Jakub
Jakub, thanks for the quick response. Can this be done via script? Do you know of an online example or tutorial? Finally, how will I know what the value of apache-user is? Assuming I'm doing this via script on theme install, it needs to be completely dynamic.
Scott B
Scott, this is linux command line level. And you can find out by checking what user apache is running under (if that is your web server). Otherwise chmod the files with r/w/x permissions. This will not be scripted.
Jakub