| @@ -3,25 +3,29 @@ | ||
| 3 | 3 | * Template for displaying extra info in backend user profile. |
| 4 | 4 | * |
| 5 | 5 | * @author ThimPress |
| 6 | 6 | * @package LearnPress/Views |
| 7 | - * @version 4.0.0 | |
| 7 | + * @version 4.0.3 | |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | +use LearnPress\Helpers\Template; | |
| 11 | +use LearnPress\Models\UserModel; | |
| 12 | + | |
| 10 | 13 | defined( 'ABSPATH' ) || die; |
| 11 | 14 | |
| 12 | 15 | /** |
| 13 | 16 | * @var WP_User $user |
| 14 | 17 | */ |
| 15 | - | |
| 16 | 18 | if ( empty( $user ) ) { |
| 17 | 19 | return; |
| 18 | 20 | } |
| 19 | 21 | |
| 20 | -$extra_profile_fields = learn_press_get_user_extra_profile_fields(); | |
| 22 | +$extra_profile_fields = learn_press_social_profiles(); | |
| 21 | 23 | $extra_profile = learn_press_get_user_extra_profile_info( $user->ID ); |
| 22 | 24 | |
| 23 | 25 | $custom_profile = lp_get_user_custom_register_fields( $user->ID ); |
| 26 | +$userModel = new UserModel( $user->data ); | |
| 27 | +$lp_message = LP_Request::get_param( 'lp-message' ); | |
| 24 | 28 | ?> |
| 25 | 29 | |
| 26 | 30 | <h3><?php esc_html_e( 'LearnPress User Profile', 'learnpress' ); ?></h3> |
| 27 | 31 | |
| @@ -26,61 +30,57 @@ | ||
| 26 | 30 | <h3><?php esc_html_e( 'LearnPress User Profile', 'learnpress' ); ?></h3> |
| 27 | 31 | |
| 28 | 32 | <table class="form-table"> |
| 29 | 33 | <tbody> |
| 30 | - <?php | |
| 31 | - $custom_fields = LP_Settings::instance()->get( 'register_profile_fields' ); | |
| 34 | + <?php | |
| 35 | + do_action( 'learn-press/admin/user/layout/general-info-custom', $user, $custom_profile ); | |
| 32 | 36 | |
| 33 | - if ( $custom_fields ) { | |
| 34 | - foreach ( $custom_fields as $field ) { | |
| 37 | + if ( current_user_can( 'edit_users' ) ) { | |
| 38 | + ?> | |
| 39 | + <tr> | |
| 40 | + <th> | |
| 41 | + <label> | |
| 42 | + <?php esc_html_e( 'LP slug user name', 'learnpress' ); ?> | |
| 43 | + </label> | |
| 44 | + </th> | |
| 45 | + <td> | |
| 46 | + <input class="regular-text" | |
| 47 | + type="text" | |
| 48 | + value="<?php echo esc_attr( $userModel->get_slug_link() ); ?>" | |
| 49 | + name="lp_user_slug"> | |
| 50 | + <?php | |
| 51 | + if ( ! empty( $lp_message ) ) { | |
| 52 | + Template::print_message( $lp_message, 'error' ); | |
| 53 | + } | |
| 35 | 54 | ?> |
| 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> | |
| 55 | + <p class="description"> | |
| 41 | 56 | <?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 | - } | |
| 57 | + printf( | |
| 58 | + '%s', | |
| 59 | + esc_html__( 'Custom slug to replace the WP login username, use for link lp profile/instructor. Must be unique.', 'learnpress' ) | |
| 60 | + ); | |
| 63 | 61 | ?> |
| 64 | - </td> | |
| 65 | - </tr> | |
| 66 | - <?php | |
| 67 | - } | |
| 68 | - } | |
| 62 | + </p> | |
| 63 | + </td> | |
| 64 | + </tr> | |
| 65 | + <?php | |
| 66 | + } | |
| 69 | 67 | |
| 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 } ?> | |
| 68 | + foreach ( $extra_profile_fields as $key => $label ) { | |
| 69 | + $type = apply_filters( 'learn-press/extra-profile-field-type', 'text' ); | |
| 70 | + ?> | |
| 71 | + <tr> | |
| 72 | + <th> | |
| 73 | + <label for="learn-press-user-profile-<?php echo esc_attr( $key ); ?>"> | |
| 74 | + <?php echo esc_html( $label ); ?> | |
| 75 | + </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 | 85 | </tbody> |
| 86 | 86 | </table> |