3

I'm using the wpForo plugin to create custom profile pages on the front end of my website.

The profile URLs generated by the wpForo plugin look like this:

example.com/community/profile/username/

example.com/community/account/username/

I managed to rewrite these URLs internally by editing some of the core plugin files. (Yes, I know, very dirty.) Now these urls looks like this, but they obviously lead to non-existing pages, showing a 404 error.

example.com/user/username/

example.com/user/username/account/

Can I use WordPress's rewrite rules to basically display the wpForo profile page on the edited URLs? I tried the following, but it doesn't work.

function custom_wpforo_rewrite_urls() { 
    // Regex returns these matches

    /*
        0 = community/profile/username/
        1 = profile
        2 = username
    */

    add_rewrite_rule('/community\/(.*)\/(.*)\//', 'user/$matches[2]/$matches[1]', 'top');

} add_action('init', 'custom_wpforo_rewrite_urls');

Which should result in the following URLs working... But they don't.

example.com/user/username/profile/

example.com/user/username/account/

  • you're using a mix of internal and external rewrites format- internal rewrites must point to index.php and set the necessary query vars to result in a successful main query. – Milo Oct 17 '16 at 15:18
  • @Milo So just for clarification. Do I need to use an internal or an external rewrite format to get the desired effect? – Swen Oct 17 '16 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.