Last active
December 11, 2023 14:36
-
-
Save Alimir/31f451c16a930481aa8555aa218ba39f to your computer and use it in GitHub Desktop.
add custom fields to register form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wp_ulike_pro_custom_after_signup_process( &$args ){ | |
// Get current user id | |
$meta_args = array(); | |
$meta_args['phone'] = ! empty( $_POST['phone'] ) ? $_POST['phone'] : null; | |
$meta_args['user-role'] = ! empty( $_POST['user-role'] ) ? array( $_POST['user-role'] ) : null; | |
foreach ($meta_args as $key => $value) { | |
update_user_meta( $args->data['user_id'], $key, $value ); | |
} | |
} | |
add_action( 'wp_ulike_pro_after_signup_process', 'wp_ulike_pro_custom_after_signup_process', 10, 1 ); | |
function wp_ulike_pro_customize_signup_form( $type, $args ){ | |
if( $type === 'signup' ){ | |
?> | |
<div class="ulp-flex-col-xl-12 ulp-flex-col-md-12 ulp-flex-col-xs-12"> | |
<div class="ulp-floating"> | |
<input id="ulp-new-phone" type="number" class="ulp-floating-input" name="phone" type="text" | |
placeholder="Phone" required /> | |
<label for="ulp-new-phone" class="ulp-floating-label" data-content="phone"> | |
<span class="ulp-hidden-visually">Phone</span> | |
</label> | |
</div> | |
</div> | |
<div class="ulp-flex-col-xl-12 ulp-flex-col-md-12 ulp-flex-col-xs-12"> | |
<div class="ulp-floating"> | |
<select name="user-role" id="ulp-user-role" class="ulp-floating-input" required> | |
<option value="editor">Editor</option> | |
<option value="author">Author</option> | |
</select> | |
<label for="ulp-user-role" class="ulp-floating-label" data-content="user-role"> | |
<span class="ulp-hidden-visually">User role</span> | |
</label> | |
</div> | |
</div> | |
<?php | |
} | |
} | |
add_action( 'wp_ulike_pro_forms_before_submit', 'wp_ulike_pro_customize_signup_form', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment