Code provided by Vibetheme does not work

Home Forums Legacy Support 4.0 Bugs & Issues Code provided by Vibetheme does not work

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #355979
    brayan_lachowsky
    Spectator
    I was given this code https://gist.github.com/MrVibe/8d60d4ce6b8703779c27fcc51261f1a3?fbclid=IwAR3C4n_EZC1uHaHUat8EOzzL6bdPJqfQwknkvUDDNdXjhYMXkr3etobXWUM I just want to add another input for username, but the code does not work please check.
    #356100
    Anshuman Sahu
    Keymaster
    Well that code is just indication how to add a field but it does not server the purpose of adding the username field . please use this code to add a username field :
    add_filter('vibebp_vars',function($vars){
        $vars['settings']['registration_fields'][]=['type'=>'text','id'=>'username','label'=>_x('Username','login','vibebp'),'value'=>'','class'=>'input'];
        return $vars;
    });
    //Process custom field
    add_filter('vibebp_register_user_bypass',function($flag,$body){
        if(is_array($body)){
            foreach($body as $key => $value){
                if($value['type'] == 'username' && !empty($value['value'])){
                    if(username_exists( $value['value'] )){
                    	$flag = 0;
                    }
                }
            }
        }
    	return $flag;
    },10,2);
    //Process custom field
    add_filter('vibebp_register_user_args_signup',function($user_args,$body){
        if(is_array($body)){
            foreach($body as $key => $value){
                if($value['type'] == 'username' && !empty($value['value'])){
                    $user_args['user_login'] = $value['value'];
                }
            }
        }
    
        return $user_args;
    },10,2);
    NOTE : this code will only work with VIBEbp version 1.5.6+
    #356153
    brayan_lachowsky
    Spectator
    Thank you Alex for the code, however, the username is not saved it gets replaced with the email, kindly check again the code
    #356352
    Anshuman Sahu
    Keymaster
    Im sorry please use the updated code :
    
    add_filter('vibebp_vars',function($vars){
        $vars['settings']['registration_fields'][]=['type'=>'text','id'=>'username','label'=>_x('Username','login','vibebp'),'value'=>'','class'=>'input'];
        return $vars;
    });
    //Process custom field
    add_filter('vibebp_register_user_bypass',function($flag,$body){
        if(is_array($body)){
            foreach($body as $key => $value){
                if($value['id'] == 'username' && !empty($value['value'])){
                    if(username_exists( $value['value'] )){
                    	$flag = 0;
                    }
                }
            }
        }
    	return $flag;
    },10,2);
    //Process custom field
    add_filter('vibebp_register_user_args_signup',function($user_args,$body){
        if(is_array($body)){
            foreach($body as $key => $value){
                if($value['id'] == 'username' && !empty($value['value'])){
                	
                    $user_args['user_login'] = $value['value'];
                }
            }
        }
    
        return $user_args;
    },10,2);
    #356366
    brayan_lachowsky
    Spectator
    AWESOME! Thank you ALEX I appreciate your quick support, you can close the topic now!
    #356393
    Ada
    Participant
    Thank-you for confirming. Closing this ticket.
Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Code provided by Vibetheme does not work’ is closed to new replies.