Forked from tpkemme/lifterlms-custom-profile-fields.php
Last active
July 9, 2018 14:46
Revisions
-
Thomas Patrick Levy revised this gist
Sep 5, 2017 . 1 changed file with 9 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,11 +12,18 @@ function add_company_industry_lifterlms ( $fields , $screen ) { if( strcmp( $screen , 'checkout' ) == 0 || strcmp( $screen , 'registration' ) == 0) { $company_industries = array( 'industry_1' => 'Industry 1', 'industry_2' => 'Industry 2', 'industry_3' => 'Industry 3', 'industry_4' => 'Industry 4', 'industry_5' => 'Industry 5', 'other' => 'Other' ); $company_industry = array( 'columns' => 12, 'id' => 'llms_company_industry', 'default' => 'other', 'label' => __('Company Industry', 'lifterlms'), 'last_column' => false, 'options' => $company_industries, -
Thomas Patrick Levy revised this gist
Aug 7, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -86,6 +86,7 @@ function validate_company_name( $validated , $data, $screen ){ } add_filter( 'lifterlms_user_registration_data' , 'validate_company_name', 10 , 3 ); add_filter( 'lifterlms_user_update_data' , 'validate_company_name', 10 , 3 ); /** -
Thomas Patrick Levy revised this gist
Aug 7, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -98,7 +98,7 @@ function validate_company_name( $validated , $data, $screen ){ */ function save_custom_company_name( $person_id, $data , $screen ){ update_user_meta( $person_id, 'llms_company_name', $data['llms_company_name'], true); } add_action( 'lifterlms_user_registered', 'save_custom_company_name', 10, 3); add_action( 'lifterlms_user_updated', 'save_custom_company_name', 10, 3); @@ -114,7 +114,7 @@ function save_custom_company_name( $person_id, $data , $screen ){ */ function save_custom_company_industry( $person_id, $data , $screen ){ update_user_meta( $person_id, 'llms_company_industry', $data['llms_company_industry'], true); } add_action( 'lifterlms_user_registered', 'save_custom_company_industry', 10, 3); add_action( 'lifterlms_user_updated', 'save_custom_company_industry', 10, 3); -
Thomas Patrick Levy revised this gist
Aug 7, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -101,6 +101,7 @@ function save_custom_company_name( $person_id, $data , $screen ){ add_user_meta( $person_id, 'llms_company_name', $data['llms_company_name'], true); } add_action( 'lifterlms_user_registered', 'save_custom_company_name', 10, 3); add_action( 'lifterlms_user_updated', 'save_custom_company_name', 10, 3); /** @@ -116,3 +117,4 @@ function save_custom_company_industry( $person_id, $data , $screen ){ add_user_meta( $person_id, 'llms_company_industry', $data['llms_company_industry'], true); } add_action( 'lifterlms_user_registered', 'save_custom_company_industry', 10, 3); add_action( 'lifterlms_user_updated', 'save_custom_company_industry', 10, 3); -
Thomas Patrick Levy revised this gist
Jun 7, 2017 . 2 changed files with 18 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ <?php // don't copy this line to your functions.php file add_action( 'llms_reporting_student_tab_info_stab_after_content', 'my_output_custom_field_data' ); function my_output_custom_field_data() { $student = isset( $_GET['student_id'] ) ? $_GET['student_id'] : null; if ( ! $student ) { return; } ?> <div class="d-1of4"> <ul> <li><strong><?php _e( 'Industry', 'lifterlms' ); ?></strong></li> <li><?php echo get_user_meta( $student, 'llms_company_industry', true ); ?></li> </ul> </div> <?php } -
tpkemme revised this gist
Jan 9, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php // don't copy this line to your functions.php file /** * * Create Company Industry as a custom field upon registration or checkout -
tpkemme revised this gist
Jan 9, 2017 . No changes.There are no files selected for viewing
-
tpkemme revised this gist
Jan 9, 2017 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ /** * * Create Company Industry as a custom field upon registration or checkout -
tpkemme created this gist
Jan 9, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,118 @@ /** * * Create Company Industry as a custom field upon registration or checkout * * @param $fields - fields already being registered * @param $screen - either checkout or registration screen * @return $fields - array with added field */ function add_company_industry_lifterlms ( $fields , $screen ) { if( strcmp( $screen , 'checkout' ) == 0 || strcmp( $screen , 'registration' ) == 0) { $company_industries = array('Industry 1', 'Industry 2', 'Industry 3', 'Industry 4', 'Industry 5', 'Other'); $company_industry = array( 'columns' => 12, 'id' => 'llms_company_industry', 'default' => 'Other', 'label' => __('Company Industry', 'lifterlms'), 'last_column' => false, 'options' => $company_industries, 'required' => false, 'type' => 'select', ); array_push($fields, $company_industry); } return $fields; } add_filter( 'lifterlms_get_person_fields', 'add_company_industry_lifterlms', 10, 2); /** * * Create Company name as a custom field upon registration or checkout * * @param $fields - fields already being registered * @param $screen - either checkout or registration screen * @return $fields - array with added field */ function add_company_name_lifterlms ( $fields , $screen ) { if( strcmp( $screen , 'checkout' ) == 0 || strcmp( $screen , 'registration' ) == 0) { $company_name = array( 'columns' => 12, 'id' => 'llms_company_name', 'label' => __('Company Name', 'lifterlms'), 'last_column' => false, 'required' => true, 'type' => 'text' ); array_push($fields, $company_name); } return $fields; } add_filter( 'lifterlms_get_person_fields', 'add_company_name_lifterlms', 10, 2); /** * * Validate Company Name * * Company name should be at least 2 characters long * * @param $validated - current validation status * @param $data - data being passed for validation * @param $screen - $screen should be registration or checkout * @return $validated - whether or not the company is valid */ function validate_company_name( $validated , $data, $screen ){ if( strcmp( $screen , 'checkout' ) == 0 || strcmp( $screen , 'registration' ) == 0){ // Make sure company name is at least characters long if( strlen( $data[ 'llms_company_name' ] ) < 2 ){ return new WP_Error( 'error-code', 'Company Name needs to be at least 2 characters', 'my-text-domain' ); } } return $validated; } add_filter( 'lifterlms_user_registration_data' , 'validate_company_name', 10 , 3 ); /** * * Save company name to usermeta table * * @param $person_id - id of user registering or checking out * @param $data - data being passed through to be saved * @param $screen - screen is either registration or checkout */ function save_custom_company_name( $person_id, $data , $screen ){ add_user_meta( $person_id, 'llms_company_name', $data['llms_company_name'], true); } add_action( 'lifterlms_user_registered', 'save_custom_company_name', 10, 3); /** * * Save company industry field to usermeta table * * @param $person_id - id of user registering or checking out * @param $data - data being passed through to be saved * @param $screen - screen is either registration or checkout */ function save_custom_company_industry( $person_id, $data , $screen ){ add_user_meta( $person_id, 'llms_company_industry', $data['llms_company_industry'], true); } add_action( 'lifterlms_user_registered', 'save_custom_company_industry', 10, 3);