Skip to:

Someone Update Say My Name Plugin

Viewing 10 replies - 1 through 10 (of 10 total)
  • Doesn’t look like it’d be too hard to update. That said, what’s broken?

    Okay, 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


    Thank you Kawauso for your help on this. Search by display , sometimes people put @kawauso, and it’s case sensitive.

    * 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="">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

    $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 ) )

    /* $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;



    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() )

    global $user_id;

    if( is_smn( $user_id ) )
    $checked = ' checked="checked"';
    $checked = '';

    <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%">
    <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>
    add_action( 'extra_profile_info', 'smn_profile' );

    function smn_edit() {
    global $user_id;

    if( $_POST[ 'smn' ] )
    bb_update_usermeta( $user_id, "smn", true );
    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;
    return false;

    Take out the /* */ around the commented out parts of the code if you want to re-enable the foreach() 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 :P 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 @ :P

    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.

    thank you! there is one more plugin but I’m figuring I have to start a new thread.

    Probably a good idea, let me know how this one works :P

    Warning: Cannot modify header information – headers already sent by (output started at /homepages/0/d188981313/htdocs/kiaspeed2/mu/forums/my-plugins/say-my-name/smn.php:3) in /homepages/0/d188981313/htdocs/kiaspeed2/mu/forums/bb-includes/ on line 708

    Warning: Cannot modify header information – headers already sent by (output started at /homepages/0/d188981313/htdocs/kiaspeed2/mu/forums/my-plugins/say-my-name/smn.php:3) in /homepages/0/d188981313/htdocs/kiaspeed2/mu/forums/bb-includes/ on line 709

    WPMU+BB+BP if it matters

    Output starts on line 3 of the plugin.. that’s either part of the description or the opening of the first function. Neither should generate anything. Check for whitespace around the PHP tags?

    ah! didn’t even realize it matters. So far so good thanks! can you email me?

    It matters when it’s involved with a filter or action that’s run on a processing page (that you don’t usually see), because if any text is passed it can’t send a redirect header for the nice pretty page you normally see straight away. Whatcha need an email for?

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar