Search Results for 'code'
-
AuthorSearch Results
-
September 28, 2009 at 12:09 am #79885
In reply to: Link Cloaking
johnhiler
MemberYou could wrap your links in code like this:
https://bbpress.org/forums/topic/check-if-a-user-is-logged-in#post-19953
September 27, 2009 at 11:28 pm #79883In reply to: Link Cloaking
Adam Harley (Kawauso)
Member<?php
/*
Plugin Name: Remove Links (conditional)
Description: Removes links for non-registered users. Based on <a href="http://ckon.wordpress.com/2007/07/12/bbpress-plugin-bb-tweaks/">bb tweaks</a>.
Plugin URI: https://bbpress.org/forums/topic/hide-links
Version: 0.01
*/
function bb_strip_links( $text ) {
global $topic;
$forums = array(
1,
2,
3,
);
if ( !in_array( $topic->forum_id, $forums ) )
return $text;
if ( !bb_current_user_can( 'write_post' ) )
$text = preg_replace('|<a (.+?)>(.+?)</a>|i', __('(Login or register to download)'), $text);
return $text;
}
add_filter('post_text', 'bb_strip_links');
?>September 27, 2009 at 6:46 pm #79866In reply to: Benefit of integrating WP/bbPress
chrishajer
ParticipantMany people want integration so that your users can log in to either bbPress or WordPress and not have to log in again when they switch from blog to forum, or forum to blog.
Others want ‘deep integration’ so they can use WordPress functions (like
get_sidebar,get_footerandget_header) in their bbPress installation. Sometimes they want deep integration to make the two themes look similar or identical. Sometimes they want to be able to pull WordPress information into bbPress or vice-versa.I integrated a forum with a blog one time but I normally have no use for it. It’s not worth the trouble for me, and I don’t need integration of users or functions.
September 27, 2009 at 3:54 pm #79326In reply to: Widgets for bbpress?
chrishajer
ParticipantMarius- please stick to one topic per post. I thought this was about widgets then I see this comment about removing the tags bar. If you want to remove the tags, just look in your template files for wherever the tag cloud is displayed, and remove that code. I don’t see a link to your forum so I can’t tell you exactly what to remove.
I think tags are normally attached to each topic, and also to the front page, and you would need to remove the places where tags can be added as well. Just find those sections in your template files, and delete them or comment them out. Make a copy of all the files first in case you make a mistake and need to revert back.
September 27, 2009 at 2:37 pm #50311In reply to: Combined Register + Post
Adam Harley (Kawauso)
MemberOkay, after much lucky guessing with regards to the user object handling, I have an ALPHA VERSION of a plugin to do this. There’s nothing to stop spambots, this is purely a proof of concept, I’ll try adding a captcha or something later if necessary. Email verification sounds like a royal pain though. Save the files exactly where I’ve said and as ever, make sure you leave no whitespace around the PHP tags. Apart from that, please test it but it’s your own risk if you run it on a production server.
my-plugins/register-post/load.php:
<?php
/*
Plugin Name: Register & Post
Description: Allows a user to register and make a post at the same time.
Author: Kawauso
Version: Alpha
*/
// Add the post form
add_action( 'post_post_form', 'register_post_form' );
function register_post_form() {
global $h2, $forum, $topic;
if( bb_is_user_logged_in() )
return;
// Setup the register form
$profile_info_keys = bb_get_profile_info_keys();
unset( $profile_info_keys['first_name'], $profile_info_keys['last_name'], $profile_info_keys['display_name'], $profile_info_keys['occ'], $profile_info_keys['from'], $profile_info_keys['user_url'], $profile_info_keys['interest'] );
$bb_register_error = new WP_Error;
$user_login_error = $bb_register_error->get_error_message( 'user_login' );
?>
<style type="text/css">p#post-form-forum-container{display:none}</style>
<form class="postform post-form" id="postform" method="post" action="<?php bb_uri( 'my-plugins/register-post/create.php', null, BB_URI_CONTEXT_FORM_ACTION )?>">
<h2 class="postform">Register and post?</h2>
<fieldset>
<table width="100%">
<tr class="form-field form-required required<?php if ( $user_login_error ) echo ' form-invalid error'; ?>">
<th scope="row">
<label for="user_login"><?php _e('Username'); ?></label>
<?php if ( $user_login_error ) echo "<em>$user_login_error</em>"; ?>
</th>
<td>
<input name="user_login" type="text" id="user_login" size="30" maxlength="30" value="<?php echo $user_login; ?>" />
</td>
</tr>
<?php
if ( is_array($profile_info_keys) ) :
foreach ( $profile_info_keys as $key => $label ) :
$class = 'form-field';
if ( $label[0] ) {
$class .= ' form-required required';
}
if ( $profile_info_key_error = $bb_register_error->get_error_message( $key ) )
$class .= ' form-invalid error';
?>
<tr class="<?php echo $class?>">
<th scope="row">
<label for="<?php echo $key?>"><?php echo $label[1]?></label>
<?php if ( $profile_info_key_error ) echo "<em>$profile_info_key_error</em>"; ?>
</th>
<td>
<input name="<?php echo $key?>" type="text" id="<?php echo $key?>" size="30" maxlength="140" value="<?php echo $$key?>" />
</td>
</tr>
<?php
endforeach; // profile_info_keys
endif; // profile_info_keys
?>
</table>
<br />
<?php
bb_load_template( 'post-form.php', array('h2' => $h2) );
bb_nonce_field( bb_is_topic() ? 'create-post_' . $topic->topic_id : 'create-topic' );
if ( bb_is_forum() ) {
echo '<input type="hidden" name="forum_id" value="' . $forum->forum_id . '" />' . "n";
} elseif ( bb_is_topic() ) {
echo '<input type="hidden" name="topic_id" value="' . $topic->topic_id . '" />' . "n";
}
echo "n</fieldset>n</form>n";
}my-plugins/register-post/create.php:
<?php
require_once('../../bb-load.php');
$profile_info_keys = bb_get_profile_info_keys();
unset( $profile_info_keys['first_name'], $profile_info_keys['last_name'], $profile_info_keys['display_name'], $profile_info_keys['occ'], $profile_info_keys['from'], $profile_info_keys['user_url'], $profile_info_keys['interest'] );
$user_login = '';
$user_safe = true;
$bb_register_error = new WP_Error;
if ( $_POST && 'post' == strtolower($_SERVER['REQUEST_METHOD']) ) {
$_POST = stripslashes_deep( $_POST );
$_POST['user_login'] = trim( $_POST['user_login'] );
$user_login = sanitize_user( $_POST['user_login'], true );
if ( $user_login !== $_POST['user_login'] ) {
$bad_input = true;
if ( $user_login )
$bb_register_error->add( 'user_login', sprintf( __( "%s is an invalid username. How's this one? <strong>%s</strong>" ), esc_html( $_POST['user_login'] ), $user_login ) );
else
$bb_register_error->add( 'user_login', sprintf( __( '%s is an invalid username.' ), esc_html( $_POST['user_login'] ) ) );
}
foreach ( $profile_info_keys as $key => $label ) {
if ( is_string($$key) )
$$key = esc_attr( $$key );
elseif ( is_null($$key) )
$$key = esc_attr( $_POST[$key] );
if ( !$$key && $label[0] == 1 ) {
$bad_input = true;
$$key = false;
$bb_register_error->add( $key, sprintf( __( '%s is required' ), $label[1] ) );
}
}
if ( !$bad_input ) {
// Invoke non-user post checks here
if ( !$post_content = trim($_POST['post_content']) )
bb_die(__('You need to actually submit some content!'));
if ( isset($_POST['topic']) && $forum_id = (int) $_POST['forum_id'] ) {
$topic = trim( $_POST['topic'] );
if ('' == $topic)
bb_die(__('Please enter a topic title'));
} elseif ( isset($_POST['topic_id'] ) ) {
$topic_id = (int) $_POST['topic_id'];
bb_check_admin_referer( 'create-post_' . $topic_id );
}
if ( !topic_is_open( $topic_id ) )
bb_die(__('This topic has been closed'));
// Invoke registration
$user_id = bb_new_user( $user_login, $_POST['user_email'], null );
if ( is_wp_error( $user_id ) ) { // Error creating user
foreach ( $user_id->get_error_codes() as $code )
$bb_register_error->add( $code, $user_id->get_error_message( $code ) );
if ( $bb_register_error->get_error_message( 'user_login' ) )
$user_safe = false;
} elseif ( $user_id ) { // Registration success
foreach( $profile_info_keys as $key => $label )
if ( strpos($key, 'user_') !== 0 && $$key !== '' )
bb_update_usermeta( $user_id, $key, $$key );
do_action('register_user', $user_id);
// Create the current user object
$wp_auth_object->set_current_user( $user_id );
$bb_current_user = $wp_auth_object->current;
// Do last minute post/topic checks
if ( !empty($topic) && $forum_id = (int) $_POST['forum_id'] ) {
if ( !bb_current_user_can('write_posts') )
bb_die(__('You are not allowed to post. Are you logged in?'));
if ( !bb_current_user_can( 'write_topic', $forum_id ) )
bb_die(__('You are not allowed to write new topics.'));
if ( !bb_current_user_can( 'write_topic', $forum_id ) )
bb_die(__('You are not allowed to write new topics in this forum.'));
bb_check_admin_referer( 'create-topic' );
$topic_id = bb_new_topic( $topic, $forum_id, $tags );
}
if ( !bb_current_user_can( 'write_post', $topic_id ) )
bb_die(__('You are not allowed to post in this topic.'));
// Create the new post
$post_id = bb_new_post( $topic_id, $_POST['post_content'] );
$tags = trim( $_POST['tags'] );
bb_add_topic_tags( $topic_id, $tags );
$link = get_post_link( $post_id );
$topic = get_topic( $topic_id, false );
if ( $topic->topic_posts )
$link = add_query_arg( 'replies', $topic->topic_posts, $link );
do_action( 'bb-post.php', $post_id );
if ( $post_id )
wp_redirect( $link );
else
wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
exit;
}
}
}
// If you've reached this point, there must have been an error
$user_login_error = $bb_register_error->get_error_message( 'user_login' );
if( empty( $user_login_error ) ) // For some reason, error strings are not always available (i.e. for invalid emails)
$user_login_error = __( 'Something went wrong! Check what you entered and try again.' );
bb_die( $user_login_error );September 27, 2009 at 2:19 pm #79701In reply to: Need A Project ShowOff
Atin
MemberOk, I got your concept.
However, “Need A Project” can be successful for Indian Engineering Students and you should first try to show it off to your customers i.e. indian engineering students and not here as it seems to be of no use for the guys discussing around
I will be happy to help you with your project and I hope you can understand that being an Indian I can have an idea about what they people need.
You can contact me at atingupta at live dot com.
Have a Happy Day!
September 27, 2009 at 10:54 am #79826In reply to: Add "topic author" to topic list
Adam Harley (Kawauso)
Membertopic_author()September 26, 2009 at 11:17 pm #79821In reply to: Presentation Admin panel not showing
jivago
MemberOpen your database, search table “wp_usermeta”, check meta_key “nicname” and change “meta_value” to your nicname for user admin in wordpress.
This was the problem in my case. I hope help you
Sorry for my english
September 26, 2009 at 9:12 pm #79804In reply to: Problems trying to install
chrishajer
ParticipantThe constants have different names in wp-config.php and bb-config.php. Just copy and paste the VALUES not the whole line.
bb-config.php:
define( 'BBDB_NAME', '123456789' );
define( 'BBDB_USER', '987654321' );
define( 'BBDB_PASSWORD', 'goodpassword' );
define( 'BBDB_HOST', 'localhost or something else' );wp-config.php:
define('DB_NAME', '123456789');
define('DB_USER', '987654321');
define('DB_PASSWORD', 'goodpassword');
define('DB_HOST', 'localhost or something else');For bbPress, the constants are name BBDB_ and for WordPress they’re just DB_. You can copy and paste the values, but make sure you don’t change the names from BBDB_ in your bb-config.php.
September 26, 2009 at 9:03 pm #79808In reply to: Changing font
chrishajer
ParticipantFind the class in style.css in your theme, and change the font there.
In the text box here, this takes care of it.
textarea#post_content {
font-family: arial, helvetica, sans-serif;
font-size:2.0em;
color: green;
}You can also just find
.postform textareain the style.css and add your rules there. Either way seemed to work fine.September 26, 2009 at 2:52 pm #79782In reply to: Someone Update Say My Name Plugin
Adam Harley (Kawauso)
MemberProbably a good idea, let me know how this one works
September 26, 2009 at 2:28 pm #31889Topic: Need Beta Testers for Ajaxed Chat Plugin
in forum PluginsGautam
MemberI have developed an ajaxed chat plugin, which uses phpfreechat.net script. That script has multiple themes, multiple languages, and multiple features.
There is also a settings page in which you can save various parameters/config for the script.
There can be 2 types of storages – mysql & file, default is mysql, it automatically uses the bbPress db you are using and makes
tableprefixajaxed_chattable.You can see the various commands that can be used in chat, and the FAQ at phpfreechat.net
There are 2 ways you can call the chat:
http://yoursite.com/?chator by placing this code anywhere in your template:
<?php if (function_exists('ajaxed_chat_load')) ajaxed_chat_load(); ?>Live Demo (At my test forums): http://forum.gaut.am/ (inside template) or http://forum.gaut.am/?chat (full screen)
Download Link – http://gaut.am/uploads/ajaxed-chat-1.0-beta.zip
Note – It is beta version, not a release (for now)
I still need to work on the admin settings page, but still its not too bad for now.
Comments, feedback & suggestions are welcomed!
September 26, 2009 at 2:25 pm #79780In reply to: Someone Update Say My Name Plugin
Adam Harley (Kawauso)
Member<?php
/*
* Plugin Name: Say My Name
* Plugin Description: Sends a notification email if someone mentions your name in a post (based on Notify Post by Thomas Klaiber).
* Author: <a href="http://www.ellequadro.net">Matteo Crippa</a>, updated for bbPress 1.0 by Kawauso
* Version: 0.2
*/
function say_my_name ( $post_id, $args ) {
global $bbdb, $topic;
if ( isset( $args[ 'post_id' ] ) && false !== $args[ 'post_id' ] ) // Don't run on edits
return;
$post = strtolower( $args[ 'post_text' ] );
$all_users = $bbdb->get_results( "SELECT * FROM $bbdb->users WHERE user_status=0" );
foreach( $all_users as $userdata ) {
if( !is_smn( $userdata->ID ) )
continue;
/* $notify = false;
*/ $display_name = strtolower( $userdata->display_name );
/* if( strpos( $display_name, ' ' ) === false ) { // Use word-by-word searching if the display name is one word
if( !isset( $words ) )
$words = explode( ' ', $post ); // Only create the word list if necessary
foreach ( $words as $word ) {
if( $display_name == $word || "@$display_name" == $word ) {
$notify = true;
break;
}
}
}
else*/ if( strpos( " $post", " $display_name" ) !== false || strpos( " $post", " @$display_name" ) !== false) // Always require a leading space
/* $notify = true;
if( $notify ) */{
$message = __( "Someone called you on: %1$s nn%2$s " );
@mail( $userdata->user_email, bb_get_option( 'name' ) . ':' . __( 'Notification' ), sprintf( $message, $topic->topic_title, get_topic_link( $topic_id ) ), 'From: ' . bb_get_option( 'admin_email' ) );
}
}
}
add_action( 'bb_insert_post', 'say_my_name', 1, 2 );
function smn_profile() {
if( !bb_is_user_logged_in() )
return;
global $user_id;
if( is_smn( $user_id ) )
$checked = ' checked="checked"';
else
$checked = '';
?>
</fieldset>
<fieldset>
<legend>Say My Name Notification</legend>
<p><?php _e('If you want to get an email when someone call your name in a new post.')?></p>
<table width="100%">
<tr>
<th width="21%" scope="row"><?php _e('Activate')?>:</th>
<td width="79%"><input name="smn" id="smn" type="checkbox" value="1"<?php echo $checked?> /></td>
</tr>
</table>
<?php
}
add_action( 'extra_profile_info', 'smn_profile' );
function smn_edit() {
global $user_id;
if( $_POST[ 'smn' ] )
bb_update_usermeta( $user_id, "smn", true );
else
bb_update_usermeta( $user_id, "smn", false );
}
add_action( 'profile_edited', 'smn_edit' );
function is_smn ( $user_id ) {
$user = bb_get_user( $user_id );
if ( $user->smn )
return true;
else
return false;
}
?>Take out the
/* */around the commented out parts of the code if you want to re-enable theforeach()loop method for single word display names. I couldn’t find much of a difference in speed, but then again it might be quite different on a live server. You can also just delete all that code too if you want to make the file smaller
I’ll upload this to the Extend section someday, along with the other plugin I keep meaning to finish and upload.Edit: Added support for @

This should be 100% case insensitive, but I’ve not tested with anything unicode. It’ll always look for a space before the name to avoid false positives, but if it’s at the very start of the post, it’ll still be detected.
September 26, 2009 at 1:22 pm #79778In reply to: Someone Update Say My Name Plugin
Adam Harley (Kawauso)
MemberOkay, I’ve managed to optimise the code for this a bit. I’m a bit stuck though.
At the moment, it’s checking for usernames, rather than display names and checking word-by-word. That’s fine for usernames, because they’re essentially always one word, but display names can be more than one and I intend to use those.
Explosion took 0.000307083129883 seconds
Strpos took 3.00407409668E-5 seconds
September 26, 2009 at 12:54 pm #78176In reply to: Key Master could not be created!
notprathap
MemberOh My! Thanks mazzhe! you saved my day!
September 26, 2009 at 10:03 am #79776In reply to: After upgrade cant upload when creating a post
Ashish Kumar (Ashfame)
ParticipantGreat! Knew both of them but not the fact that ipstenu is a female developer.
Actually female developers get me impressed pretty quick. I guess its cuz of my love for code and love for ladies
September 26, 2009 at 8:15 am #79773In reply to: After upgrade cant upload when creating a post
johnhiler
MemberWe have a number of female developers on the bbPress forums… they’re some of our most active members actually.

If you’re using a number of _ck_s plugins, I recommend you restore from backups and go back to 0.9 btw…
September 26, 2009 at 8:11 am #79772In reply to: After upgrade cant upload when creating a post
brad_langdon
MemberThanks, I thought CK was a dude… lol. Typical male I am
September 26, 2009 at 6:55 am #31884Topic: extra slashes with deep integration
in forum TroubleshootingMark-k
ParticipantThe problem seems to be that wordpress adds slashes to the input in its initialization, and them comes bbpress and adds slashes once again, and since the code assumes that slashes were added only once, stange things happen.
solution that work for me: in bb-settings.php change
// Sanitise external input
$_GET = bb_global_sanitize( $_GET );
$_POST = bb_global_sanitize( $_POST );
$_COOKIE = bb_global_sanitize( $_COOKIE, false );
$_SERVER = bb_global_sanitize( $_SERVER );
to
if ( !defined( 'ABSPATH' ) ) { // no need to sanitize if wp had done it
// Sanitise external input
$_GET = bb_global_sanitize( $_GET );
$_POST = bb_global_sanitize( $_POST );
$_COOKIE = bb_global_sanitize( $_COOKIE, false );
$_SERVER = bb_global_sanitize( $_SERVER );
}
September 26, 2009 at 6:48 am #79697In reply to: Need A Project ShowOff
kernow
MemberI’m impressed, it looks very good. The only problem I can see is that it reminds me that I need to learn more about coding and I don’t have the time
September 26, 2009 at 5:44 am #79724In reply to: Help! All of my images have stopped showing up!
Ashish Kumar (Ashfame)
ParticipantDoesn’t make sense if the path in the plugin bb_attachments was changed by itself
September 26, 2009 at 4:23 am #72125In reply to: Slash text issue in 1.0-alpha-6, have searched
defue
MemberI’ve found a solution for this. You need to edit bbpress/bb-includes/functions.bb-posts.php and replace the function bb_get_post (it is the first function in file) with
function bb_get_post( $post_id ) {
global $bbdb;
$post_id = (int) $post_id;
if ( false === $post = wp_cache_get( $post_id, 'bb_post' ) ) {
$post = $bbdb->get_row( $bbdb->prepare( "SELECT * FROM $bbdb->posts WHERE post_id = %d", $post_id ) );
$post = bb_append_meta( $post, 'post' );
wp_cache_set( $post_id, $post, 'bb_post' );
}
//here is the only new line for stripping slashes
$post->post_text = stripslashes($post->post_text);
return $post;
}Not sure that it is the elegant solution but it works for me.
September 26, 2009 at 3:12 am #79696In reply to: Need A Project ShowOff
Ashish Kumar (Ashfame)
ParticipantC’mon no comments on the design or implementation?
September 26, 2009 at 12:33 am #76884In reply to: call for testers on the 0.9 branch and 1.0 trunk
Josh Leuze
MemberDisregard my last post, that link is ooooold as dirt

Let’s cross our fingers that someone is on the job though!
September 25, 2009 at 10:24 pm #79753In reply to: WordPress Integration
gerikg
Memberdefine('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');replace those with the 8 keys
you do the same in bb-config.php
and add “BB_”
define('BB_AUTH_KEY', 'put your unique phrase here'); -
AuthorSearch Results