Forum Replies Created
-
I think
require_once
(orrequire
,include
orinclude_once
for that matter) need a path to the file rather than a URL. A path would be like the addresses you get when you’re browsing folders on your computer. I can’t say what your path would be, but mine is/home/username/public_html/wordpress/wp-config.php
. Ask your hosting provider if you don’t know what to use.It might be easier to recreate the theme anyway, if I remember rightly a fair few folks come here with problems when trying to stick bb into the WP theme like that.
In reply to: phpbb -> bbPress success…almost (SQL HELP!)I vaguely remember from setting up bb in localhost and trying to copy my server DB into my local MySQL that PHPMyAdmin wouldn’t take more than 16 Mb when importing. That might well be a setting that can be set somewhere, I don’t know; I can’t find it in its config file, in any case.
Edit: my localhost version of phpMyAdmin says “Max: 16,384KiB” by the import dialog.
To get around this if it is the problem, can you live without 1/3rd of the posts? Then you could delete them in the original database via some query and export the remaining 2/3rds. It might be better to hold out for someone with more database-mojo to come along and see if there’s a non-destructive way.
In reply to: Plugin: Avatar Upload* added a ‘default avatar image’ option (if you don’t want to use fel64’s identicons — see previous posts in this thread).
fel – how would you like me to link to the identicon’s plugin? Currently, I’m just linking to your post in this thread.
IMO identicons make the perfect default avatar and I would like it if you include them or at least make it an option choosable through the admin panel. (If it reassures you, the Identicon creator is happy with this being included as part of such a plugin too.)
If you don’t want to do that, again IMO this should go into a branch for your plugin (I’d need to update it first). It’s not possible to add this as a plugin so that it will work with yours, nor is it distinct enough to be its own plugin; if not part of the core plugin, I see the only alternatives to be making it a branch or just leaving it here as unofficial hack.
In reply to: adding wordpress admin linkDoes that work? It should have been:
<?php if( bb_current_user_can('administrate) ) {
$wp_admin = 'wordpress/wp-admin/';
echo '<a href="'.$wpadmin.'">Wordpress Admin</a>'; } ?>Sorry!
In reply to: adding wordpress admin linkSure. Paste this in your HTML code somewhere:
<?php if( bb_current_user_can('administrate) {
$wp_admin = 'http://link.to.your/wordpress/wp-admin/';
echo '<a href="'.$wpadmin.'">Wordpress Admin</a>'; } ?>In reply to: Include code in postsYeah, and that’s where it’s annoying because you can’t easily check if a given user has permissions. Might be worth a trac ticket request.
Possibly easiest would be to attach a filter for the post being submitted, because then you can use the
bb_current_user_can()
function.In reply to: Support for file attachments or picturesCool! Can you upload it somewhere and link to it? That way if now or later someone fancies doing it they can immediately.
In reply to: Include code in postsIf you can’t edit the template and have something against the excellent bb-Ads plugin: I can’t help you, because AFAIK there’s no straightforward API function to check what a non-current user can do.
In reply to: MathML and BBpress working togetherThanks!
You can include ASCIIMathML.js in the header via plugin by this sort of code:
`function incMathJs() {
$url = bb_path_to_url( dirname(__FILE__) . ‘/ASCIIMathML.js’)
echo ‘<script type=”text/javascript” src=”‘ . $url . ‘”>’;
}
add_action( ‘bb_head’, ‘incMathJs’ );
Not sure when or how the JS kicks in, but perhaps that’s not necessary? Anyway, you could head over to trac and request that code_trick be made pluggable (so a plugin could overwrite it).
In reply to: Show exact date of post? (not freshness)Replace
D M Y
with a date-formatted string of your choice. It’s quite an interesting but simple system. Each letter stands for a different type of date or time. SoD
is replaced by first three letters of the weekdate,M
by first three of the month etc.This reference will tell you what letters to use to see what date outputs you get. Roll your own date format.
In reply to: Site using bbpress: purposegames.comYou’ve got a really nice eye for the design of the site. It’s rare to see something so nicely designed and functional.
The main column of games could be a bit more highlighted, though; with the strong coloured backgrounds the left colum distracts a lot. Worth it for the login form, but in my opinion not for stats.
How did you get the /profiles/X thing to work? Haven’t tried it myself, but it would be interesting to know how much modification it took to have bb accept that – if any?
In reply to: Profile TabsNote that you will have to get rid of the filename check and that all that $user_id business is unnecessary and stopped my script executing. Just grab the global $user.
In reply to: Cannot select DB.Have you tried abc’s fix? You’re sure you have the right details?
In reply to: Plugin: bb-Topic-ViewsAll I did was split
display_view_count()
into two functions,display_view_count()
andget_view_count()
. If for example you wanted the views in a seperate column, you’d add the column HTML and then add<?php $view_count = get_view_count(); echo $view_count; ?>
This is what I replaced
display_view_count( $title )
with, here for Smurf’s convenience. You’re about to get mail.Oh, before I forget – hopefully now that plugins need activation in 1.0-alpha, there’s also an activation hook or the like. That would let you do a lot of preparation first, making the code much easier.
Edit: there is! bb_activate_plugin_XXX. Maybe you can use that – if you want to and figure it out, tell us/make an entry on the wiki.
function display_view_count ($title)
{
global $bbdb, $topic;
$topic_id = $topic->topic_id;
$view_count = get_view_count( $topic_id );
//Builds the text to be appended to the title
$count_display = " <em>($view_count views)</em>"; //This sets the view count var to the existing number of views, if greater than 0
//Makes this plugin play nice with the Page Links plugin by putting the pages (if they exist) on a new line
if (function_exists('page_links_add_links')) {
$count_display .= "n";
}
$title .= $count_display;
return $title;
}
function get_view_count( $topic_id )
{
$view_count = $bbdb->get_var("SELECT meta_value FROM $bbdb->topicmeta WHERE topic_id = $topic_id AND meta_key='views'");
if ( $view_count <= 0 ) {
//If the view count hasn't been initialized...
if ($topic->topic_posts >= 1) {
/* Sets the new record to the number of posts that have been made in a topic */
$view_count = $topic->topic_posts; //sets the view_count number
} else {
$view_count = 0; //can't think of a time when this would be necessary (phantom topics???)
}
//Adds the record to the DB so it isn't zero any longer
$bbdb->query("INSERT INTO $bbdb->topicmeta ( meta_id, topic_id, meta_key, meta_value) VALUES ( NULL , $topic_id, 'views', $view_count )");
}
return $view_count;
}In reply to: German LanguageThat’s not similar at all, it’s completely unrelated. You’ve posted it once, people will help you if they can – but posting it everywhere is just annoying. Please don’t.
In reply to: Plugin: bb-Topic-ViewsWittmania, it’s a really easy hack – in fact, if you simply take the code that gets the pageviews and seperate it into a different function, you could call that both from the current function you have to automatically append it and use it as a template tag. If you don’t fancy doing it, is it alright if I quickly hack it for Smurf?
In reply to: bbPulp.org – developer wikiAdded add_profile_tab as well as a top-level Capabilities page, figured that’d be useful too. Is that alright?
In reply to: Profile TabsShould really have been more familiar with the code – there’s a check to see if it’s the correct file, otherwise it simply redirects to the front page. Getting rid of that made it work.
Thanks for all your help, Sam!
In reply to: Profile TabsCheers Sam, that’s definitely the way to do it, but I can’t quite make it work. Adding the tab is easy, but following the link dumps you on the front page (if using
add_profile_tab()
) or in your profile (if adding the tab manually).function felavatartab()
{
global $profile_menu, $profile_hooks;
$profile_tab = array(__('Avatar'), 'edit_profile', 'moderate', 'avatar-upload.php', 'avatar');
$profile_menu[] = $profile_tab;
if ( can_access_tab( $profile_tab, bb_get_current_user_info( 'id' ), $user_id ) )
$profile_hooks[bb_tag_sanitize($profile_tab[4])] = $profile_tab[3];
}
add_action( 'bb_profile_menu', 'felavatartab' );OR
function felavatartab()
{
add_profile_tab(__('Avatar'), 'edit_profile', 'moderate', 'avatar-upload.php');
}
add_action( 'bb_profile_menu', 'felavatartab' );I’ve got the file
avatar-upload.php
in my root directory, which loads the templateavatar.php
. If instead you giveavatar.php
as your argument the tab doesn’t show up at all.See it here. Any idea?
In reply to: Pulling profile data from wordpressDepending on if you’ve set up bbPress so that it’s not only integrated but also uses WordPress’s functions when available, I think you can just call the WP function. If it doesn’t work, you need to make a database query along the lines of:
global $bbdb;
$profiledata = $bbdb->get_row( "SELECT meta_value FROM $bbdb->usermeta WHERE meta_key = $theprofiledetail AND user_id = $theuserid");Where $theuserid and $theprofiledetail are set to whatever you want. Note that $profiledata is worth examining by using
print_r($profiledata);
or the like, because its format can be confusing. The code might not work, but it’s an idea.In reply to: bbpress / wordpress avatar?Thank you!
For testing if it’s bb it might be easiest to do exactly what you did but with a global variable bb uses anyway, such as $bbdb or whatever you feel like – saves you having to put in the declarations.
In reply to: Views plugin help neededI’m not sure how it’s handled, but it might be worth looking at how phpBB or vBulletin or any other forum software does it.
In reply to: Hack: bb replies as wp comments; using bb API?Cheers!
Further hack here, to migrate any comments made to WP posts that have a corresponding bb topic (via the bbPress Post plugin again) as replies to the thread. Unfortunately the date/time won’t be right, it’ll be like a new post just made.
This needs to be installed/activated as a plugin to work, and to prevent it somehow accidentally happening again I suggest you immediately uninstall it. To run it, simply append “?lulz=p” to a URL and it’ll get to work – make sure you only do this once! An interface would be a lot neater, but, well, meh.
At your own risk.
<?php
/*
Plugin Name: Comments migrate
Plugin URI:
Description: moves wp comments into bb posts.
Author: fel64
Version: 0.7
Author URI: http://www.loinhead.net/
*/
function felmigrate()
{
global $bbdb, $bb_table_prefix;
//foreach blogpost/topic in wp_bbpress_post_posts
$bridge = $bbdb->get_results( ' SELECT post_id, topic_id
FROM wp_bbpress_post_posts', ARRAY_A );
foreach( $bridge as $sumthing => $link )
{
//foreach comment
$wppost = $link['post_id'];
$bbtopic = $link['topic_id'];
$felcoms = $bbdb->get_results( " SELECT comment_author, comment_date, comment_content, comment_author_IP
FROM wp_comments
WHERE comment_post_ID = $wppost" );
if( $felcoms )
{
foreach( $felcoms as $sumthing => $felcom )
{
//if valid user
$felu = bb_get_user_by_name( $felcom->comment_author );
if( $felu )
{
//create new post in that thread with said details
fel_new_post( $bbtopic, $felcom, $felu->ID );
}
}
}
}
//party
}
function fel_new_post( $topic_id, $post_details, $felID ) {
global $bbdb, $bb_cache, $bb_table_prefix, $thread_ids_cache;
$topic_id = (int) $topic_id;
$bb_post = $post_details->comment_content;
//$bb_post = apply_filters('pre_post', $bb_post, false, $topic_id);
$bb_post = htmlspecialchars( $bb_post, ENT_QUOTES );
$post_status = 0;
$now = bb_current_time('mysql');
//$now = $post_details->comment_date;
$uid = $felID;
$uname = $post_details->comment_author;
$ip = $post_details->comment_author_IP;
$topic = get_topic( $topic_id );
$forum_id = $topic->forum_id;
if ( $bb_post && $topic ) {
$topic_posts = ( 0 == $post_status ) ? $topic->topic_posts + 1 : $topic->topic_posts;
$bbdb->query("INSERT INTO $bbdb->posts
(forum_id, topic_id, poster_id, post_text, post_time, poster_ip, post_status, post_position)
VALUES
('$forum_id', '$topic_id', '$uid', '$bb_post','$now', '$ip', '$post_status', $topic_posts)");
$post_id = $bbdb->insert_id;
if ( 0 == $post_status ) {
$bbdb->query("UPDATE $bbdb->forums SET posts = posts + 1 WHERE forum_id = $topic->forum_id");
/* if( $now < $topic->topic_time )
{
$now = $topic->topic_time;
$uid = $topic->topic_last_poster;
$uname = $topic->topic_last_poster_name;
$post_id = $topic->topic_last_post_id;
}
*/ $bbdb->query("UPDATE $bbdb->topics SET topic_time = '$now', topic_last_poster = '$uid', topic_last_poster_name = '$uname',
topic_last_post_id = '$post_id', topic_posts = '$topic_posts' WHERE topic_id = '$topic_id'");
if ( isset($thread_ids_cache[$topic_id]) ) {
$thread_ids_cache[$topic_id]['post'][] = $post_id;
$thread_ids_cache[$topic_id]['poster'][] = $uid;
}
$post_ids = get_thread_post_ids( $topic_id );
if ( !in_array($uid, array_slice($post_ids['poster'], 0, -1)) )
bb_update_usermeta( $uid, $bb_table_prefix . 'topics_replied', $bb_current_user->data->topics_replied + 1 );
} else
bb_update_topicmeta( $topic->topic_id, 'deleted_posts', isset($topic->deleted_posts) ? $topic->deleted_posts + 1 : 1 );
if ( !bb_current_user_can('throttle') )
bb_update_usermeta( $uid, 'last_posted', time() );
$bb_cache->flush_one( 'topic', $topic_id );
$bb_cache->flush_many( 'thread', $topic_id );
$bb_cache->flush_many( 'forum', $forum_id );
do_action('bb_new_post', $post_id);
return $post_id;
} else {
return false;
}
}
//plunge
if( $_GET['lulz'] = 'p' )
felmigrate();
?>In reply to: tuzhak !== bozo; tuzhak === link-farmer;I’m glad these still are a pretty place.
I don’t know, closing it isn’t going to save his feelings; although closing it would be appropriate if it looks like a fight. It’s a matter of opinion I guess. Yup, clear as mud!
In reply to: tuzhak !== bozo; tuzhak === link-farmer;If you don’t mind me going into this, the discussion being over isn’t a reason to lock a thread. Even if you think (probably rightly) you just settled it, there’s a chance you haven’t or there may be something new, like this thread. It’s not like we were spamming or flaming the kid. Just like you don’t lock threads where people got their problem fixed, why would you lock them at all?
Okay, so using modlook might be good in some situations – spam bot or troll or whatever, when it’s clear cut – but without threads and talking about it you wouldn’t know it was a link farmer, for example.