Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite rule error #5

Open
geefo opened this issue Nov 20, 2017 · 3 comments
Open

Rewrite rule error #5

geefo opened this issue Nov 20, 2017 · 3 comments
Labels

Comments

@geefo
Copy link

geefo commented Nov 20, 2017

Hello, if enable option Forum Prefix, topic page return 404 error. Problem in "function add_post_types_rewrite" bbp_get_topic_slug() return "forums/topic" but add_permastruct get_option( '_bbp_topic_slug', 'topic' ) return "topic":
rewrite rule - forums/forum(.+?)forums/topic/(.+?)/?$
permastruct - forums/forum/%forumnames%/topic/%forumnames%/

if change bbp_get_topic_slug() to get_option( '_bbp_topic_slug', 'topic' ) all works

public static function add_post_types_rewrite($postType, $args)
{
    $topic_slug = get_option( '_bbp_topic_slug', 'topic' );
        
    switch ($postType) {
        case bbp_get_topic_post_type():

            // Paged topic Rule
            add_rewrite_rule(
                bbp_get_forum_slug().'(.+?)'.$topic_slug.'/(.+?)/'.bbp_get_paged_slug().'/([0-9]{1,})/?$',
                'index.php?forumnames=$matches[1]&name=$matches[2]&post_type='.$postType.'&paged=$matches[3]',
                'top'
            );
            // Edit topic rule
            add_rewrite_rule(
                bbp_get_forum_slug().'(.+?)'.$topic_slug.'/(.+?)/edit/?$',
                'index.php?forumnames=$matches[1]&name=$matches[2]&post_type='.$postType.'&'.bbp_get_edit_rewrite_id().'=1',
                'top'
            );
            // View topic rule
            add_rewrite_rule(
                bbp_get_forum_slug().'(.+?)'.$topic_slug.'/(.+?)/?$',
                'index.php?forumnames=$matches[1]&name=$matches[2]&post_type='.$postType,
                'top'
            );

            add_permastruct($postType, bbp_get_forum_slug()."%forumnames%".$topic_slug."/%postname%/", $args->rewrite);
            static::flush_rewrite_rules_if_needed();
            break;
    }
}
@JHGrove3
Copy link

I think I'm having this same problem... I'll see if I can find a way to implement the change @geefo is suggesting.

Could it be a recent change in BBPress that is causing the issue?

And a question for you, @benjamin-backend -- I see this plugin is about a year old. Are you still supporting it / working on it?

Also, have you considered asking the BBPress team to incorporate this into the BBPress plugin?

@sulfo
Copy link
Contributor

sulfo commented Dec 18, 2017

Hi @JHGrove3 and @geefo.
Thanks for the feedback!

Yes, we are still supporting it, and we will look into it soon. 👍

@sulfo sulfo added the bug label Dec 18, 2017
@JHGrove3
Copy link

Update: That fix seems to have solved the problem for me!

Now I can continue to test my integration of BBPress and Memberpress, to see if Memberpress can successfully secure the topics in my forum, not just the forums themselves.

JHGrove3 added a commit to JHGrove3/bbpress-better-permalinks that referenced this issue Dec 18, 2017
Entered the bug fix proposed by @geefo in Issue BenjaminMedia#5
BenjaminMedia#5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants