Skip to:
Content
Pages
Categories
Search
Top
Bottom

What is the difference

  • Avatar of James
    James
    Participant

    @janismo

    could someone please explain, what is the important difference (from question of localizaion) of:

    `function bpxs_check_email_confirm()
    {
    global $bp, $bpxs;

    if( $bpxs->options->email_confirmation == true )
    {
    // unset any existing errors
    unset( $bp->signup->errors );

    //check if email address is correct and set an error message for the first field if any
    $account_details = bp_core_validate_user_signup( $_POST, $_POST );

    if( ! empty( $account_details->errors ) )
    $bp->signup->errors = $account_details->errors[0];

    if( ! empty( $_POST ) )
    {
    if( empty( $_POST ) )
    $bp->signup->errors = __( ‘Please make sure you enter your email twice’, ‘bpxs’ );

    elseif( $_POST != $_POST )
    $bp->signup->errors = __( ‘The emails you entered do not match.’, ‘bpxs’ );
    }
    }
    }
    add_action(‘bp_signup_validate’, ‘bpxs_check_email_confirm’);`

    and

    `function bpxs_validate_username( $user_name )
    {
    global $wpdb;

    $maybe = array();
    preg_match( “/[a-z0-9]+/”, $user_name, $maybe );

    $db_illegal_names = get_option( ‘illegal_names’ );
    $filtered_illegal_names = apply_filters( ‘bp_core_illegal_usernames’, array( ‘www’, ‘web’, ‘root’, ‘admin’, ‘main’, ‘invite’, ‘administrator’, BP_GROUPS_SLUG, BP_MEMBERS_SLUG, BP_FORUMS_SLUG, BP_BLOGS_SLUG, BP_REGISTER_SLUG, BP_ACTIVATION_SLUG ) );

    $illegal_names = array_merge( (array)$db_illegal_names, (array)$filtered_illegal_names );

    if( ! validate_username( $user_name ) || $user_name != $maybe[0] )
    $error = __( ‘Only lowercase letters and numbers allowed.’, ‘bpxs’ );

    if( in_array( $user_name, (array)$illegal_names ) )
    $error = __( ‘This username is reserved. Please chose another one.’, ‘bpxs’ );

    if( strlen( $user_name ) < 4 )
    $error = __( ‘Username must be at least 4 characters.’, ‘bpxs’ ) ;

    if( strpos( ‘ ‘ . $user_name, ‘_’ ) != false )
    $error = __( ‘Usernames must not contain the character “_”!’, ‘bpxs’ ) ;

    $match = array();
    preg_match( ‘/[0-9]*/’, $user_name, $match );

    if( $match[0] == $user_name )
    $error = __( ‘Usernames must contain letters too!’, ‘bpxs’ ) ;

    $error = apply_filters( ‘bpxs_custom_error’, $error, $user_name );

    return $error;
    }`

    after loading textdomains both codes are translated (in one plugin), but issue is that first is recognized by multilingual plugins, but second is not. if issue is in global $wpdb;, how can I pass round it?

    thanks.

You must be logged in to reply to this topic.