mrhoratio (@mrhoratio)

Forum Replies Created

Viewing 25 replies - 1 through 25 (of 45 total)
  • Strange, I was able to use spaces in mine. Perhaps it has to do with punctuation marks in the string.

    Can you post the lines you added to your wp-config.php and bb-config.php files?

    The line defining the secret key in bb-config.php should look something like this:

    define('BB_SECRET_KEY', 'My Secret Key');

    and in wp-config.php

    define('SECRET_KEY', 'My Secret Key');

    Don’t forget the BB_ in fron of SECRET_KEY in the bb-config.php file.

    In reply to: Public forums

    For spam control/moderation, perhaps it tied in more tightly with Akismet. WordPress blogs allows anonymous commenting this way.

    Hi Sam, I was able to fix this without messing with bb_repermalink. Instead I used a plugin filter for get_user_profile_link(), get_topic_link(), and get_forum_link() functions.

    Here’s the thread:

    How to shorten a profile link?

    https://bbpress.org/forums/topic/nicer-slug-url-rewrite-plugin-done

    By the way, I made this hack cleaner by implementing it as a filter inside a plugin.

    function my_get_user_profile_link_filter( $link , $user_id = 0 ) {
    //check for rewrite
    $rewrite = bb_get_option( 'mod_rewrite' );
    if ( $rewrite ) {
    //what kind of rewrite there is? slug use "forum_slug" column, else the column is "forum_id"
    $column = ($rewrite === 'slugs')?('forum_slug'):('forum_id');
    $link = str_replace('forums/profile/', 'people/', $link);
    }
    return $link; // Very important line!
    }

    This was based on code suggested in another thread:

    https://bbpress.org/forums/topic/nicer-slug-url-rewrite-plugin-done

    You’re welcome. It’s included with 2.5.1, it’s just an optional entry, so I don’t think it would be in your default config file. But I think it is shown in the sample config file.

    https://codex.wordpress.org/Editing_wp-config.php#Secret_Key_IMPORTANT

    Add this line to your wp-config.php file.

    define(‘SECRET_KEY’, ‘Your bbPress Secret Key’);

    Replace Your bbPress Secret Key with your bbPress secret key. I believe the developers already know about this. By the way, make sure you have the latest WordPress installation. I believe secret key is a new functionality in WordPress 2.5.

    I had the same problem, and thought I had the same secret keys, but actually didn’t when I checked my config files.

    Did you manually check your wp-config.php and bb-config.php files to make sure the secret keys are defined and are matching?

    IPsource, to add a Forum button in the nav bar, you’ll need to edit your theme files in WordPress. And then do the same in the bbPress template files. Most likely, the files would be something called header.php. Every theme is different so it’ll depend on what you have. You might consider hiring a coder to do it, if you’re not comfortable with the html/php.

    Make sure your SECRET_KEY in both WordPress and bbPress are the same. This is covered on this thread:

    https://bbpress.org/forums/topic/troubleshoot-integration

    Nevermind my last post. You can just swap the positions of line 43 and 45, in bb-post.php, and it works. Not sure why, but it does.

    IPSource,

    The short answer is you have to convert your WordPress theme to bbPress by hand.

    I’m currently doing the same thing you’re trying to do on my WordPress blog with bbPress also. It pretty much means taking your WordPress theme and going through each file one by one and converting them to bbPress. So you have to strip out the WordPress tags and functions in the theme files and replace them with bbPress versions. There’s no list of equivalent tags, so translating them is just gonna take a lot of trial and error and testing.

    I discovered another issue with this hack. If you write a new post in a new topic, after the submitting the form, you are redirected back to the forum’s front page, instead of the forum you were on. I spent some time digging around the get_post_link() related functions, and couldn’t figure out exactly what was going on. However, I was able to make this modification to the bb-post.php file to get it to redirect properly.

    Paste this after line 43, in bb-post.php of bbPress 0.9.0.2

    $link = str_replace('forums/', "forums/". $forum->$topic_slug, $link);

    Hey Sam, thanks for making a ticket for this. I was able to query for topics within a date from directly from WordPress as well. Here’s something I wrote to merge “super sticky” bbPress topics into the WordPress loop. It’s a bit of hack, but it brings the “Promote to Front Page” functionality of Drupal into WordPress/bbPress:

    <?php get_header(); ?>

    <?php

    //Put WordPress posts into an array
    $wp_posts = $posts;

    if (!is_single()){

    //Retrieve first post of previous page (we need this post's date to query bbPress topics
    $offset=$paged*$posts_per_page+$posts_per_page;
    $first_post_of_previous_page = get_posts('numberposts=1&offset='.$offset);

    //First set the start and end dates to limit the query to the bbPress table
    $startdate=(date('YmdHis',strtotime($first_post_of_previous_page[0]->post_date_gmt)));

    //If it's the most recent page, set end date to today
    if ($paged){
    $enddate=(date('YmdHis',strtotime($wp_posts[0]->post_date_gmt)));
    } else {
    $enddate=gmdate('YmdHis');
    }

    //Retrieve "Super Sticky" topics from bbPress tables
    //This assumes your bbPress and WordPress tables are in the same database
    $bb_topics = $wpdb->get_results("SELECT * FROM bb_topics WHERE topic_sticky = 2 AND topic_start_time BETWEEN $startdate AND $enddate ORDER BY topic_start_time DESC");

    //Map bbPress topics to WordPress posts structure
    foreach($bb_topics as $bb_topic){
    $bb_first_post = $wpdb->get_results("SELECT post_text FROM bb_posts WHERE post_position = '1' AND topic_id = $bb_topic->topic_id", ARRAY_A);
    $bb_post->ID = "forum_topic_".$bb_topic->topic_id;
    $bb_post->post_author = $bb_topic->topic_poster;
    $bb_post->post_date = $bb_topic->topic_start_time;
    $bb_post->post_content = $bb_first_post[0][post_text];
    $bb_post->post_title = $bb_topic->topic_title;
    $bb_post->post_status = "publish";
    $bb_post->comment_status = "open";
    $bb_post->ping_status = $bb_topic->post_id;
    $bb_post->post_name = "forums/topic/".$bb_topic->topic_slug;
    $bb_post->post_type = "post";
    $bb_post->comment_count = $bb_topic->topic_posts-1;

    //add bbPress topic to WordPress posts array
    $wp_posts[] = $bb_post;

    };

    //Create function to sort array of posts by date
    function compare($x, $y){
    if ( $x->post_date == $y->post_date )
    return 0;
    else if ( $x->post_date < $y->post_date )
    return 1;
    else
    return -1;
    }

    //Sort array
    usort($wp_posts,'compare');
    }

    ?>

    <div id="content-box" class="span-8">

    <div id="content-area" class="clearfix">

    <?php if ($wp_posts): ?>
    <?php foreach ($wp_posts as $post): ?>
    <?php setup_postdata($post); ?>

    <div class="entry">

    <div class="entry-header clearfix">

    <div class="info span-2">
    <a href="<?php the_permalink(); ?>#comments" class="comment-activity"><?php comments_number('<strong>Post comment</strong>', '<strong>1</strong> Comment', '<strong>%</strong> Comments' );?></a>
    </div><!-- end info -->

    <div class="content span-6 last">
    <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    </div><!-- end content -->

    </div><!-- end entry-header -->

    <div class="entry-content clearfix">

    <div class="info span-2 clearfix">
    <p><strong><?php the_author() ?></strong><br />
    <?php the_time('M j, Y'); ?>
    </p>
    <p class="share-this"><?php akst_share_link(); ?></p>

    <p class="post-comment"><a href="<?php the_permalink(); ?>#respond">Comment</a></p>

    </div><!-- end info -->

    <div class="content span-6 last clearfix">

    <?php the_content('Click to continue'); ?>

    <p class="entry-tags"><?php the_tags('<strong>Posted in: </strong>', ', ', ''); ?> </p>

    </div><!-- end content -->

    </div><!-- end entry-content -->

    </div><!-- end entry -->

    <?php endforeach; ?>

    <?php include (TEMPLATEPATH . '/navigation.php'); ?>

    <?php else : ?>

    <h2 class="page_header center">Not Found</h2>
    <div class="entry">
    <p class="center">Sorry, but you are looking for something that isn't here.</p>
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    </div>

    <?php endif; ?>

    </div><!-- end content-area-->

    </div><!-- end content-box -->

    <?php get_sidebar(); ?>

    <?php get_footer(); ?>

    Okay, I think I got it working.

    I was able to fix the redirection issue by modifying the get_user_profile_link() function in the template-functions.php. I added the following line towards the end of the function, right before the last line of code in the function:

    $r = str_replace('forums/profile/' . $user->$column , "profile/" . $user->$column, $r);

    This is the full code:

    function get_user_profile_link( $id = 0, $page = 1 ) {
    $user = bb_get_user( bb_get_user_id( $id ) );
    $rewrite = bb_get_option( 'mod_rewrite' );
    if ( $rewrite ) {
    if ( $rewrite === 'slugs' ) {
    $column = 'user_nicename';
    } else {
    $column = 'ID';
    }
    $r = bb_get_option('uri') . "profile/" . $user->$column . ( 1 < $page ? "/page/$page" : '' );
    } else {
    $r = bb_get_option('uri') . "profile.php?id=$user->ID" . ( 1 < $page ? "&page=$page" : '' );
    }

    $r = str_replace('forums/profile/' . $user->$column , "profile/" . $user->$column, $r);

    return apply_filters( 'get_user_profile_link', $r, $user->ID );
    }

    I noticed that if you did not install bbPress with WordPress cookie integration, then this hack will cause bbPress to always think you are logged out. I think it has something with it not being able to retrieve the cookie because of the path change.

    However, if you have WordPress cookie integration enabled, then everything seems to work. Not exactly sure why. But I think it must be something to with the path that’s being set in the cookie.

    In reply to: Rewriting?

    Hey I’m been trying to get this to work also. And have posted to some other similar threads here, but there haven’t gotta a solution working.

    Here’s what I’ve learned.

    1. From what I gathered, the problem is with how bbPress redirects its pages. Even if you have the proper mod_rewrite rules, bbPress will automatically redirect the rewritten URL to the full URL that it thinks the page is supposed to have. This basically makes custom mod_rewrite useless.

    2. You can prevent bbPress from redirecting by fooling bbPress into thinking it should have a different URL than its supposed to. You can do this by modifying the get_forum_link, get_topic_link, get_user_profile link, etc. functions in the template-functions.php file. The idea is to use pattern matching to strip out the base directory from the URL.

    function get_user_profile_link( $id = 0, $page = 1 ) {
    $user = bb_get_user( bb_get_user_id( $id ) );
    $rewrite = bb_get_option( 'mod_rewrite' );
    if ( $rewrite ) {
    if ( $rewrite === 'slugs' ) {
    $column = 'user_nicename';
    } else {
    $column = 'ID';
    }
    $r = bb_get_option('uri') . "profile/" . $user->$column . ( 1 < $page ? "/page/$page" : '' );
    } else {
    $r = bb_get_option('uri') . "profile.php?id=$user->ID" . ( 1 < $page ? "&page=$page" : '' );
    }

    $r = str_replace('forums/profile/' . $user->$column , "profile/" . $user->$column, $r);
    return apply_filters( 'get_user_profile_link', $r, $user->ID );
    }

    3. If you strip out the base directory from the URL however, it makes bbPress think you’re no longer logged in, and you can’t log in. I still can’t figure out a fix yet.

    Seems like a lot of people are having issues with mod_rewrite in bbPress. Hopefully the next update will resolve some of these issues.

    In reply to: Rewriting up one level

    Sambauers,

    As you suggested, I was able to modify get_user_profile_link() function in template-functions.php to prevent the redirection. Mod_rewrite will now rewrite to the profile page properly, without redirecting it.

    But now, it shows I’m no longer logged in when I’m on a rewritten page, even though I am. When I try to log in. It just reloads the page.

    Here’s the mod in_user_profile_link():

    function get_user_profile_link( $id = 0, $page = 1 ) {
    $user = bb_get_user( bb_get_user_id( $id ) );
    $rewrite = bb_get_option( 'mod_rewrite' );
    if ( $rewrite ) {
    if ( $rewrite === 'slugs' ) {
    $column = 'user_nicename';
    } else {
    $column = 'ID';
    }
    $r = bb_get_option('uri') . "profile/" . $user->$column . ( 1 < $page ? "/page/$page" : '' );
    } else {
    $r = bb_get_option('uri') . "profile/" . $user->$column . ( 1 < $page ? "/page/$page" : '' );

    }
    $r = str_replace('forums/profile/' . $user->$column , "profile/" . $user->$column, $r);
    return apply_filters( 'get_user_profile_link', $r, $user->ID );

    }

    My goal is create a short URL such as http://www.example.com/profile/username

    TheSage, there’s a solution for your problem now at this thread:

    nicer slug url rewrite plugin (done!)

    and someone’s turned it into a plugin here:

    http://www.technospot.net/blogs/how-to-remove-forum-and-topic-keyword-from-bbpress-url/

    Perhaps this idea of a single profile page for both WordPress and bbPress will be part of the recently accounted backPress.

    It would great to have a profile link such as:

    http://www.example.com/member/username

    that works for both WordPress and bbPress. Instead of separate ones at:

    http://www.example.com/forums/profile/username or

    `http://www.example.com/author/username

    I’ve tried mod_rewrite, but running into problems with the wp_redirect functions in bbPress redirecting the page after the URL has been rewritten, so that the URL changes back to the longer form.

    For example, this mod_rewrite rule:

    RewriteRule ^profile/username forums/profile/username [L]

    will rewrite:

    http://www.example.com/profile/username

    to:

    http://www.example.com/forums/profile/username

    Except, that after its been rewritten, bbPress forces a redirection, causing the URL in the browser window to change to the longer form.

    It looks like it indeed breaks something. If you comment out wp_redirect in the functions.php, you will be able to use mod_rewrite to rewrite a URL to a bbPress page. However, this breaks authentication, and causes bbPress to think you are not logged in, even if you are. Not sure how to fix this.

    It looks like the culprit is the wp_redirect function() which includes the header() function. This function appears in several bbPress files. I’m not exactly sure what the intent of them are.

    In the functions.php file, I commented out lines 2061 and 2062 in the bbPress functions.php file:

    if ( $check != $uri && $check != str_replace(urlencode($_original_id), $_original_id, $uri) ) {
    //wp_redirect( $permalink );
    //exit;
    }

    This seems to be helping with the problem. Not sure if it’s going to break something else though.

Viewing 25 replies - 1 through 25 (of 45 total)