Forums

Enabling permalinks outside admin (2 posts)

  1. shashanky
    Member
    Posted 2 years ago #

    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.

  2. shashanky
    Member
    Posted 2 years ago #

    hello,
    any one with any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic