Skip to:
Content
Pages
Categories
Search
Top
Bottom

Displayname check

  • @barabajen

    Member

    Displayname check – forbid to take already taken display name?’

    Is it possible to have a check if a displayname is used or not. So that it can only be one displayname identity. As it is with login-names.

    Thanks

Viewing 18 replies - 1 through 18 (of 18 total)
  • @kawauso

    Member

    @barabajen

    Member

    Actually i Want to people to be able to use a certain displayname. But not to take a Displayname that has already been taken. (to make my users to be able to use swedishletters and odd symbols in their name.

    @kawauso

    Member

    Mostly managed to write something, need to work on the error page though.

    @kawauso

    Member
    <?php
    /*
    Plugin Name: No Duplicate Display Names
    Description: Prevents users from using already existing display names.
    */

    function check_display_name ( $user_id ) {

    global $bbdb, $bb_current_id, $display_name;

    $name_query = <<<EOQ
    SELECT
    user_login
    FROM
    $bbdb->users
    WHERE
    display_name = "$display_name"
    AND
    ID != "$bb_current_id"
    EOQ;

    if ( $name_clash = $bbdb->get_var( $name_query ) ) {
    wp_redirect( add_query_arg( 'nameclash', $name_clash, get_user_profile_link( $user->ID ) ) );
    exit;
    }

    }

    add_action ( 'before_profile_edited', 'check_display_name' );

    ?>

    You also need in your theme’s profile.php, before the line <?php elseif ( $user_id == bb_get_current_user_info( ‘id’ ) ) : ?>

    <?php elseif ( $_GET['nameclash'] ) : ?>
    <div class="notice error">
    <p><?php printf(__('Display name already taken by %s'), $_GET['nameclash' ]); ?>. <a href="<?php profile_tab_link( $user_id, 'edit' ); ?>"><?php _e('Edit again »'); ?></a></p>
    </div>

    Also, I just set my display name to a SQL query string, yay :D

    @barabajen

    Member

    Hmmm Got this error message:

    Warning: Unexpected character in input: ” (ASCII=92) state=1 in /home/bajentes/public_html/bbpress/my-plugins/no-duplicate-displayname/no-duplicate-displayname.php on line 2

    Parse error: syntax error, unexpected T_STRING in /home/bajentes/public_html/bbpress/my-plugins/no-duplicate-displayname/no-duplicate-displayname.php on line 2

    What to do….

    @barabajen

    Member

    Ah – problem fixed. Text was screwed up.

    next problem:

    Warning: Cannot modify header information – headers already sent by (output started at /home/bajentes/public_html/bbpress/my-plugins/no-duplicate-displayname/no-duplicate-displayname.php:32) in /home/bajentes/public_html/bbpress/bb-includes/functions.bb-pluggable.php on line 232

    @kawauso

    Member

    Check for an extra line or space after the closing ?> tag, seems to be a common problem copying from the forums. Or an extra line or space before the <?php tag.

    @barabajen

    Member

    kawuso,

    you´re brilliant!

    @barabajen

    Member

    kawuso,

    Is it possible to make the plugin to “forbid” or dont register a change to a displayname that has already been taken.

    As it is now, you get a errormessage. But if you ignore the message telling you to edit. you can still post replys in a already taken displayname…

    @kawauso

    Member

    That’s… weird, and slightly worrying. Unless you mean can it stop people already registered with a duplicate name already? It could, but that’d be easily avoidable by never editing your profile. If it’s registering changes to an already existing display name from a different one though, there’s something very wrong, because it’s run before anything is saved and has a hard stop put in right after the redirect.

    @barabajen

    Member

    kawuso,

    like this,

    If this was my forum I´d go to edit my profile and try to use change my name to show to yours. What happens is that i get the error message that tells me to edit my displayname again.

    If I instead ignore the message and go back to the forum – I´ll have your name as name with my avatar.

    @kawauso

    Member

    How fun, your install is ignoring a exit (die) command :D got a link to your forum?

    That or 1.0.2 is radically different in how it structures when that function is called D:

    @barabajen

    Member

    @kawauso

    Member

    I couldn’t reproduce getting the error, only changing and getting the okay message. No idea why that is, but my money is because of MySQL and UTF-8. Maybe someone else can fix that, but I definitely can’t for now.

    @gerikg

    Member

    Kawauso, you buddypress knowledgeable, I want to use this on my site but I don’t use bbpress registration.

    @barabajen

    Member

    kawuso,

    thanks for your help. I´ll let it stay the way it is. If our user ignores the errormessage I´ll suppose they have to be handled in other ways.

    Thanks again

    @kawauso

    Member

    @gerikg: There’s far more chance that someone has written something like this for WordPress in their plugin database

    @gerikg

    Member

    Thanks Kawauso, haven’t had luck finding it though.

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