• I am trying to set permalinks to a custom structure without requiring the user login as admin.
    I wrote a small plugin as given below

    add_filter(‘init’, ‘my_rewrite_rules’);
    function my_rewrite_rules() {
    global $wp_rewrite;
    $wp_rewrite->set_permalink_structure(‘/%year%/%monthnum%/%day%/%postname%/’);
    $wp_rewrite->flush_rules();
    }

    The permalink structure is changed and the links now reflect the right structure; However .htacess is not updated and I get a 404 page not found.

    I have searched a lot for a solution but it seems that the only way to make $wp_rewrite->flush_rules write to .htacess is as admin or by using an admin hook (e.g. admin_init). But I need .htacess to be written without going in as admin.

    I found that an action called permalink_structure_changed is created by set_permalink_structure() but adding an action to that hook also didnt work.

    Any help would be greatly appreciated.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Enabling permalinks outside admin’ is closed to new replies.