Home › Forums › Legacy Support › 4.0 Bugs & Issues › Code provided by Vibetheme does not work
- This topic has 5 replies, 3 voices, and was last updated 3 years, 10 months ago by
Ada.
Viewing 6 posts - 1 through 6 (of 6 total)
-
AuthorPosts
-
May 4, 2021 at 9:53 pm #355979
brayan_lachowsky
SpectatorI 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.May 5, 2021 at 1:45 pm #356100Anshuman Sahu
KeymasterWell 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 :
NOTE : this code will only work with VIBEbp version 1.5.6+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);
May 5, 2021 at 5:48 pm #356153brayan_lachowsky
SpectatorThank you Alex for the code, however, the username is not saved it gets replaced with the email, kindly check again the codeMay 6, 2021 at 4:06 pm #356352Anshuman Sahu
KeymasterIm 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);
May 6, 2021 at 7:56 pm #356366brayan_lachowsky
SpectatorAWESOME! Thank you ALEX I appreciate your quick support, you can close the topic now!May 7, 2021 at 4:07 am #356393Ada
ParticipantThank-you for confirming. Closing this ticket. -
AuthorPosts
Viewing 6 posts - 1 through 6 (of 6 total)
- The topic ‘Code provided by Vibetheme does not work’ is closed to new replies.