• Hello, I’ve added some more fields in Learnpress student registration page through code I added to functions.php: Tel number, gender… etc. How can I display these information in the orders page via code and without using any plugins?
    here is the code I added to functions.php:

    
    /**
     * Add new fields above 'Update' button.
     *
     * @param WP_User $user User object.
     */
    function qf_additional_profile_fields($user) {    ?>
    
        <h3>Extra profile information</h3>
        <table class="form-table">
    	 <tr>
    		 <th><label for="gender">Gender</label></th>
       		 <td>
       			 <input type="radio" name="gender" value="Male" <?php if(is_object($user) && esc_attr(get_user_meta($user->ID, 'gender', true))== 'Male'){echo 'checked';} ?>> Male   			 
    			 <input type="radio" name="gender" value="Female" <?php if(is_object($user) && esc_attr(get_user_meta($user->ID, 'gender', true))== 'Female'){echo 'checked';} ?>> Female   			 
       		 </td>
       	 </tr>
       	 <tr>
    		 <th><label for="mobile">Mobile Number</label></th>
       		 <td>
       			 <input type="text" name="mobile" value="<?php if(is_object($user)){echo esc_attr(get_user_meta($user->ID, 'mobile', true));} ?>">   			 
       		 </td>
       	 </tr>
       	 <tr>
    		 <th><label for="parentmobile">Parent Mobile Number</label></th>
       		 <td>
       			 <input type="text" name="parentmobile" value="<?php if(is_object($user)){echo esc_attr(get_user_meta($user->ID, 'parentmobile', true));} ?>">   			 
       		 </td>
       	 </tr>
        </table>
        <?php
    }
    add_action( 'show_user_profile', 'qf_additional_profile_fields' );
    add_action( 'edit_user_profile', 'qf_additional_profile_fields' );
    add_action( 'user_new_form', 'qf_additional_profile_fields' );
    
    //-----------------------
    /**
     * Save additional profile fields.
     *
     * @param  int $user_id Current user ID.
     */
    function qf_save_profile_fields($user_id) {
    
        if ( ! current_user_can( 'edit_user', $user_id ) ) {
       	 return false;
        }
        
    	if ( empty($_POST['mobile']) || empty($_POST['parentmobile']) || empty($_POST['gender'])){
    		return false;
        }
    
        update_usermeta( $user_id, 'mobile', $_POST['mobile'] );
    	update_usermeta( $user_id, 'parentmobile', $_POST['parentmobile'] );
    	update_usermeta( $user_id, 'gender', $_POST['gender'] );
    }
    
    add_action( 'personal_options_update', 'qf_save_profile_fields' );
    add_action( 'edit_user_profile_update', 'qf_save_profile_fields' );
    add_action( 'user_register', 'qf_save_profile_fields' );
    //------------------------------------------------------------
    

    Thank you.

    • This topic was modified 4 years, 4 months ago by mashour06.
    • This topic was modified 4 years, 4 months ago by mashour06.
    • This topic was modified 4 years, 4 months ago by mashour06.
Viewing 1 replies (of 1 total)
  • Hi mashour06,

    Please change it in file wp-content\plugins\learnpress\templates\checkout\order-received.php

Viewing 1 replies (of 1 total)
  • The topic ‘display extra info in orders page in LearnPress’ is closed to new replies.