I need to add new dynamic roles in my wordpress's .htaccess
I just do it using the following script:
$f = fopen(".htaccess", "a+");
fwrite($f, "your content");
fclose($f);
...but I need to write before the WP comments:
# BEGIN WordPress
Wp roles...
# END WordPress
is is possibile, by PHP to write in a specific section of my .htaccess?
You could use flush_rules
(codex). A hard flush will actually rewrite the .htaccess
.
You can combine it together with add_rewrite_rule()
(codex), and generally all the Rewrite_API.
I would not recommend to use your own function to do that, and it is also not recommended to call this function on each load - it can greatly reduce performance.