| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying extra info in backend user profile. |
| 4 |
* |
| 5 |
* @author ThimPress |
| 6 |
* @package LearnPress/Views |
| 7 |
* @version 4.0.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
defined( 'ABSPATH' ) || die; |
| 11 |
|
| 12 |
/** |
| 13 |
* @var WP_User $user |
| 14 |
*/ |
| 15 |
|
| 16 |
if ( empty( $user ) ) { |
| 17 |
return; |
| 18 |
} |
| 19 |
|
| 20 |
$extra_profile_fields = learn_press_get_user_extra_profile_fields(); |
| 21 |
$extra_profile = learn_press_get_user_extra_profile_info( $user->ID ); |
| 22 |
|
| 23 |
$custom_profile = lp_get_user_custom_register_fields( $user->ID ); |
| 24 |
?> |
| 25 |
|
| 26 |
<h3><?php esc_html_e( 'LearnPress User Profile', 'learnpress' ); ?></h3> |
| 27 |
|
| 28 |
<table class="form-table"> |
| 29 |
<tbody> |
| 30 |
<?php |
| 31 |
$custom_fields = LP_Settings::instance()->get( 'register_profile_fields' ); |
| 32 |
|
| 33 |
if ( $custom_fields ) { |
| 34 |
foreach ( $custom_fields as $field ) { |
| 35 |
?> |
| 36 |
<tr> |
| 37 |
<th> |
| 38 |
<label for="learn-press-custom-register-<?php echo esc_attr( $field['id'] ); ?>"><?php echo esc_html( $field['name'] ); ?></label> |
| 39 |
</th> |
| 40 |
<td> |
| 41 |
<?php |
| 42 |
switch ( $field['type'] ) { |
| 43 |
case 'text': |
| 44 |
case 'number': |
| 45 |
case 'email': |
| 46 |
case 'url': |
| 47 |
case 'tel': |
| 48 |
?> |
| 49 |
<input name="_lp_custom_register[<?php echo esc_attr( $field['id'] ); ?>]" type="<?php echo esc_attr( $field['type'] ); ?>" class="regular-text" value="<?php echo esc_attr( $custom_profile[ $field['id'] ] ?? '' ); ?>"> |
| 50 |
<?php |
| 51 |
break; |
| 52 |
case 'textarea': |
| 53 |
?> |
| 54 |
<textarea name="_lp_custom_register[<?php echo esc_attr( $field['id'] ); ?>]"><?php echo isset( $custom_profile[ $field['id'] ] ) ? esc_textarea( $custom_profile[ $field['id'] ] ) : ''; ?></textarea> |
| 55 |
<?php |
| 56 |
break; |
| 57 |
case 'checkbox': |
| 58 |
?> |
| 59 |
<input name="_lp_custom_register[<?php echo esc_attr( $field['id'] ); ?>]" type="<?php echo esc_attr( $field['type'] ); ?>" value="1" <?php echo isset( $custom_profile[ $field['id'] ] ) ? checked( $custom_profile[ $field['id'] ], 1 ) : ''; ?>> |
| 60 |
<?php |
| 61 |
break; |
| 62 |
} |
| 63 |
?> |
| 64 |
</td> |
| 65 |
</tr> |
| 66 |
<?php |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
foreach ( $extra_profile_fields as $key => $label ) { |
| 71 |
$type = apply_filters( 'learn-press/extra-profile-field-type', 'text' ); |
| 72 |
?> |
| 73 |
<tr> |
| 74 |
<th> |
| 75 |
<label for="learn-press-user-profile-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></label> |
| 76 |
</th> |
| 77 |
<td> |
| 78 |
<input id="learn-press-user-profile-<?php echo esc_attr( $key ); ?>" |
| 79 |
class="regular-text" type="<?php echo esc_attr( $type ); ?>" |
| 80 |
value="<?php echo esc_attr( $extra_profile[ $key ] ?? '' ); ?>" |
| 81 |
name="_lp_extra_info[<?php echo esc_attr( $key ); ?>]"> |
| 82 |
</td> |
| 83 |
</tr> |
| 84 |
<?php } ?> |
| 85 |
</tbody> |
| 86 |
</table> |
| 87 |
|