Web Analytics Made Easy -
StatCounter How would I prevent using special characters in this? - CodingForum

Announcement

Collapse
No announcement yet.

How would I prevent using special characters in this?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How would I prevent using special characters in this?

    I would like to prevent a person from using a space or special character in their username when registering for my Joomla community builder site. I had this in a previous version but since I've upgraded I'm not sure how to do this again.

    Here is where I think the new line should be:
    PHP Code:
        function prepareFieldDataSave( &$field, &$user, &$postdata$reason ) {
            global 
    $_CB_framework$ueConfig;

            
    $this->_prepareFieldMetaSave$field$user$postdata$reason );

            switch ( 
    $field->name ) {
                case 
    'username':
                    if ( ! ( ( 
    $ueConfig['usernameedit'] == ) && ( $reason == 'edit' ) && ( $_CB_framework->getUi() == ) ) ) {
                        
    $username                =    stripslashescbGetParam$postdata'username'null ) );
                        
    $fieldMinLength            =    $field->params->get'fieldMinLength');
                        if ( 
    cbIsoUtf_strlen$username ) < $fieldMinLength ) {
                            
    $this->_setValidationError$field$user$reasonsprintf_UE_VALID_UNAME_UE_UNAME$fieldMinLength ) );
                        } else {
                            if ( 
    $this->validate$field$user$field->name$username$postdata$reason ) ) {
                                if ( ( 
    $username !== null ) && ( $username !== $user->username ) ) {
                                    
    $this->_logFieldUpdate$field$user$reason$user->username$username );
                                }
                            }
                        }
                        if ( 
    $username !== null ) {
                            
    $user->username        =    $username;
                        }
                    }
                    break; 
    Here's what I had in the old version:
    PHP Code:
            IF(($ueConfig["usernameedit"]==1) or ($user->username=="") or ($ui == 2)) { 

                
    $return .= "<input class=\"inputbox\" type=\"text\" size=\"40\" id=\"username\" name=\"username\" value=\"".htmlspecialchars($user->username)."\" />";

                
    $return .= getFieldIcons($uitrue,($ueConfig["name_format"]!=1),sprintf_VALID_AZ09_UE_UNAME) , _UE_UNAME.":");



                
    $_PLUGINS->loadPluginGroup('user');

                
    $usernameSpecialsResults    =    $_PLUGINS->trigger'onUsernameSpecials', array( $ui$user->id ) );

                if ( 
    is_array$usernameSpecialsResults ) ) {

                    
    $return    .=    ' ' implode' '$usernameSpecialsResults );

                }



            } else {

                
    $return .= $user->username;

                
    $return .= "<input class=\"inputbox\" type=\"hidden\" name=\"username\" value=\"".htmlspecialchars($user->username)."\" />";

            }

            
    $return .= "\n</td>\n</tr>\n"
    Anyone have any idea how to do this in the new code?
    Last edited by sfraise; Apr 2, 2009, 03:19 AM.

  • #2
    How you did it before up gradation?

    Comment

    Working...
    X