Overview

Classes

  • Bright
  • BrightWoocommerceConstants
  • BrightWoocommerceIntegration
  • WoocommerceExtensions

Functions

  • bright_add_quicktags
  • bright_add_token_tag
  • bright_call_api_for_course
  • bright_check_compat
  • bright_curl
  • bright_curl_error
  • bright_echo_message
  • bright_extract_embed_code
  • bright_fetch_template_text
  • bright_fetch_user_attributes
  • bright_get_authentication_code_for_user
  • bright_get_avatar_url
  • bright_get_course_data
  • bright_get_course_list_with_registrations
  • bright_get_course_providers
  • bright_get_registration_data
  • bright_get_registration_list
  • bright_get_reportage_urls
  • bright_get_template_data
  • bright_get_user
  • bright_learning_paths_load_bright_customization_scripts
  • bright_load_custom_wp_admin_style
  • bright_load_scripts
  • bright_log
  • bright_manage_woocommerce_order
  • bright_menu_admin
  • bright_menu_overview
  • bright_menu_settings
  • bright_menu_sync
  • bright_message
  • bright_register_user_to_course
  • bright_render_as_javascript
  • bright_reset_token
  • bright_results_matrix
  • bright_return_as_javascript
  • bright_rewrite_embed_code
  • bright_run_stored_query
  • bright_set_current_course_provider
  • bright_shortcode_func
  • bright_stop
  • bright_stub
  • bright_support
  • bright_template_pack_load_bright_customization_scripts
  • bright_template_pack_load_bright_customization_styles
  • bright_update_all_users
  • bright_update_realmuser_meta
  • bright_update_user_licenses
  • bright_update_user_meta
  • btp_create_header_text
  • dump_bright_js_for_footer
  • setup_bright_menu
  • Overview
  • Class
  1: <?php
  2: 
  3: global $bright_update_user_meta;
  4: 
  5: function bright_log($message,$doecho=false) {
  6:   $trace=debug_backtrace();
  7:   $c=$trace[1];
  8:   if (isset($c['class']))
  9:     $caller = $c['class'] . '::' . $c['function'];
 10:   else
 11:     $caller = $c['function'];
 12: 
 13:   $caller .= ' - ';
 14: 
 15:   if ($doecho)
 16:     if ( is_array($message) || is_object($message) ) 
 17:       echo var_dump("{$caller}{$message}");
 18:     else
 19:       echo "<pre class=\"xdebug-var-dump\">{$caller}{$message}</pre>";
 20:   if ( WP_DEBUG === true ) {
 21:     if ( is_array($message) || is_object($message) ) 
 22:       error_log( $caller .print_r($message, true) );
 23:     else 
 24:       error_log( $caller . $message );
 25:   }
 26: }
 27: 
 28: /* add_action('edit_user_profile_update', 'update_extra_profile_fields'); */
 29:  
 30: /* function update_extra_profile_fields($user_id) { */
 31: /*   global $bright_update_user_meta; */
 32: 
 33: /*   if (!isset($bright_update_user_meta)) */
 34: /*  $bright_update_user_meta = array(); */
 35: 
 36: /*   array_push($bright_update_user_meta, $user_id); */
 37: /* } */
 38: 
 39: /* /\* add_action( 'shutdown', 'bright_shutdown', 10, 0); *\/ */
 40: 
 41: /* function bright_shutdown() { */
 42: /*   global $bright_update_user_meta; */
 43:   
 44: /*   bright_log("in bright_shutdown"); */
 45: /*   foreach ($bright_update_user_meta as &$user_id) { */
 46: /*  bright_update_user_meta("id",$user_id); */
 47: /*   } */
 48: /* } */
 49: 
 50: function bright_update_all_users($args) {
 51:   $skiptoday = $args['skip-today'];
 52:   $max_records = $args['max-records'];
 53: 
 54:   global $wpdb;
 55:   $sql = "SELECT ID, user_email FROM " . $wpdb->prefix . "users";
 56:   $myrows = $wpdb->get_results($sql);
 57: 
 58:   global $bright_curl_error;
 59:   $today = date("d-m-Y");
 60:   $recno = 0;
 61:   foreach ( $myrows as $user ) {
 62:     /* echo "Processing Bright User MetaData for {$user->user_email}<br/>"; */
 63:     $current = get_user_meta($user->ID, 'bright-last-fullsync',true);
 64:     if (!empty($skiptoday) && $current === $today) {
 65:       echo "Skipped Bright User MetaData for {$user->user_email} {$bright_curl_error}<br/>";
 66:       next;
 67:     } else {
 68:       echo "Updated Bright User MetaData for {$user->user_email} {$bright_curl_error}<br/>";
 69:       bright_update_user_meta('id',$user->ID);
 70:       if(! isset($bright_curl_error)) 
 71:         add_user_meta($user->ID, 'bright-last-fullsync',$today,true) || update_user_meta($user->ID, 'bright-last-fullsync',$today);
 72:       $recno++;
 73:       if (!empty($max_records) && $recno >= $max_records)
 74:         break;
 75:     }
 76:   }
 77: }  
 78: 
 79: function bright_update_user_meta($field,$learner) {
 80:   $current_user = ($field === "bright_user") ? $learner : get_user_by($field,$learner);
 81:   if (!empty($current_user)){
 82:     bright_log('updating user meta for '. $current_user->user_email);
 83:     Bright::realm_user_gcustom($current_user->user_email,bright_fetch_user_attributes($current_user));
 84:   } else {
 85:     echo '<span class="error">skipping null record for {$id} {$learner}</span><br/>';
 86:   }
 87: }
 88: 
 89: add_action( 'profile_update', 'bright_update_realmuser_meta', PHP_INT_MAX, 2 ); /* run last!!!!! */
 90: 
 91: function bright_update_realmuser_meta( $user_id, $old_user_data) {
 92:   bright_log("in function bright_update_realmuser_meta (profile_update)");
 93:   bright_update_user_meta("id",$user_id);
 94: }
 95: 
 96: /* DEBUGGING ONLY */
 97: 
 98: /* add_filter('bright_extend_on_course','test_user_management',5,3);  */
 99: 
100: /* function test_user_management($raw_course_data,$course_id,$raw_registration_data) { */
101: /*   Bright::realm_user_gcustom(bright_get_user()->user_email,bright_fetch_user_attributes()); */
102: /*   return $raw_course_data; */
103: /* } */
104: 
API documentation generated by ApiGen