I have managed to do pretty much everything I wanted.


I have managed to do pretty much everything I wanted.
The only thing left is that I need to add 2 fields in the Student registration pop up (using Coursepress theme): City and Country
And then I need to pass this submitted info to databse and show it in students profile.

Ive been trying to follow https://premium.wpmudev.org/forums/topic/student-registration-page-customizing

But no luck.

Please help

  • Salvador Ramirez

    Thank you.

    OK, lets say I want to add one field in teh registraion page (pop up of the template): "student_location" (obviously I will add more once I know this one works).

    This is what I have done:

    1. wp-content/plugins/coursepress/coursepress.php

    Added in line 1651:
    $student_data[ 'student_location' ] = $posted_data[ 'student_student_location' ];

    And added in line 1664:
    $email_args[ 'student_student_location' ] = $student_data[ 'student_location' ];

    2. wp-content/plugins/coursepress/themes/coursepress/functions.php


    <strong>add_action('user_register', 'student_signup');
    function student_signup($user_id)
        $location = isset($_POST['student_student_location']) ? $_POST['student_student_location'] : null;
        update_user_meta($user_id, 'student_location', $location);
    add_filter( 'user_contactmethods', 'perfil_usuario_personalizado' );
    function perfil_usuario_personalizado( $user_contact ) {
    	$user_contact['perfil_linkedin'] = __('Linkedin');
    	$user_contact['perfil_twitter'] = __('Twitter');
        $user_contact['perfil_web_personal'] = __('Web personal');
        $user_contact['perfil_lema'] = __('Tu lema como profesional del sector:');
    	$user_contact['perfil_especialidades'] = __('Tus especialidades en recursos humanos:');
    	<blockquote>$user_contact['student_location'] = __('País:');
        return $user_contact;</blockquote>

    This last bits adds the Student location field in the Users admin page.

    3. wp-content/plugins/coursepress/themes/cincludes/popup-window-signup.php

    Added in the form:

    <label class="cp_popup_col_2">
    			<input type="text" name="student_student_location" class="" id="cp_popup_student_location" placeholder="<?php _e( 'student_location', 'cp' ); ?>" />


    The overall result is that the field is successfully added in the registration form, and the field is also added in the users admin area. HOWEVER the info entered in the form is not passed to the database, and thus not shown in the admin area. I also want to show that info in the students profile page, but I think that will not be a problem once the variable is passed from teh form.

    Thank you !

  • Tyler Postle

    Hey there Salvador,

    Hope you're doing well today and thanks for your patience!

    I'm working with one of our developers on this, do you mind sending in your FTP and WP access? Then we can take a closer look at the files you have and get this sorted out :slight_smile:

    You can send that info in through our private contact form: https://premium.wpmudev.org/contact/

    Send in:

    Subject: "Attn: Tyler Postle"
    -WordPress admin username
    -WordPress admin password
    -login url
    -FTP credentials (host/username/password)
    -link back to this thread for reference
    -any other relevant urls

    Select "I have a different question" for your topic - this and the subject line ensure that it gets assigned to me :slight_smile:


    Look forward to hearing from you!

    All the best,

  • Tyler Postle

    Hey Salvador,

    Very sorry for the delay here :slight_frown:

    I've received your credentials and just passed them on to the developer I was discussing this with earlier. They will be notified for when they are online next :slight_smile:

    Thanks a ton for all your patience! Do you have any further questions I could help you with in the meantime? Just let me know.

    Hope you're having a great day!


  • Hoang Ngo

    Hey Salvador,

    I hope you are well today and I'm sorry for the delay.

    First off, please backup your code now and revert it back to original, as CoursePress is very active development for new feature, so if you modify the plugin code, each time you upgrade it, you will need to put the code back.

    Instead of modify plugin code, we can use the hook/filter system. You can create a new plugin, called it CoursePress custom signup
    For adding new fields to register form, please add this code to your new created plugin

    add_action( 'coursepress_after_all_signup_fields', 'custom_field_cp_signup' );
    function custom_field_cp_signup() {
    $location = isset($_POST['student_location']) ? $_POST['student_location'] : null;
    $field_2 = isset($_POST['example_field_2']) ? $_POST['example_field_2'] : null;
    <label class="cp_popup_col_2">
    			<input type="text" name="student_location" class="" id="cp_popup_student_location" value="<?php echo $location; ?>" />
    <label class="cp_popup_col_2">
    			<input type="text" name="example_field_2" class="" id="example_field_2" value="<?php echo $location; ?>" />

    So I assume your form has done, now we will process the custom fields data after user submit the form

    add_action('user_register', 'student_signup');
    function student_signup($user_id)
        $location = isset($_POST['student_location']) ? $_POST['student_location'] : null;
        update_user_meta($user_id, 'student_location', $location);
    $example_field_2 = isset($_POST['example_field_2']) ? $_POST['example_field_2'] : null;
        update_user_meta($user_id, 'example_field_2', $example_field_2);

    The code above is an example for adding new fields and store that fields value when new user sign up. You can base on that and adding more fields to fit with your need. If you got any questions about coding, your are more than welcome to posting here, so I can help.

    Also, please try to avoid to modify the plugin code, at it will lost after you update to new version :slight_smile:

    Thanks a ton for your patience here.

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.