Skip to content

Instantly share code, notes, and snippets.

@MrVibe
Created April 27, 2021 05:25
Show Gist options
  • Save MrVibe/8d60d4ce6b8703779c27fcc51261f1a3 to your computer and use it in GitHub Desktop.
Save MrVibe/8d60d4ce6b8703779c27fcc51261f1a3 to your computer and use it in GitHub Desktop.
Custom fields in Registration popup v4
//Add custom field
add_filter('vibebp_vars',function($vars){
$vars['settings']['registration_fields'][]=['type'=>'text','id'=>'XXXXX','label'=>_x('WPLMS Purchase Code','login','vibebp'),'value'=>'','class'=>'input'];
return $vars;
});
//Process custom field
add_filter('vibebp_register_user_bypass',function($flag,$body){
foreach($body as $key => $value){
if($value['type'] == 'password'){
if(empty(sanitize_text_field($value['value'])))
return 0;
}
if($value['type'] == 'email'){
if(empty(sanitize_text_field($value['value'])))
return 0;
}
if($value['id'] == 'XXXXX'){
if(empty($purchase_code)){
return 0;
}else{
//Perform action
return 1;
}
}
}
return 0;
},10,2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment