Reputation: 925
Basically I am creating a theme for my blog and I need to set the customcss.css
to writable 777
so that when I change the design in the backend it writes to this file.
Everything works 100% when I set the chmod
to 777
manually, but when I try to set the chmod to 777
when activating it display this error message:
Warning: chmod(): Operation not permitted in /var/www/vhosts/domainname.com/wptest/wp-content/themes/ctheme/ThemeFunctions/themeinstall.php on line 74
The code I am using is as follows:
$rootpage = get_theme_root();
chmod($rootpage . '/ctheme/css/customcss.css', 0777);
I have searched this website and unfortunately found nothing similar. What am I doing wrong?
Upvotes: 0
Views: 1040
Reputation: 198109
When you execute the command manually, you are a user in the shell that is allowed to change the mode.
When you write the php function chmod
into the script, it will be executed by another user, the user that is executing PHP.
Because that user is not allowed to change the mode of the file. That is why you see the error.
Unless you do not change the user that is executing PHP (to change the user that is then finally changing the mode), this error will not go away.
Upvotes: 1