当前位置: 首页>>代码示例>>PHP>>正文


PHP WooThemes_Sensei_Utils::add_user_data方法代码示例

本文整理汇总了PHP中WooThemes_Sensei_Utils::add_user_data方法的典型用法代码示例。如果您正苦于以下问题:PHP WooThemes_Sensei_Utils::add_user_data方法的具体用法?PHP WooThemes_Sensei_Utils::add_user_data怎么用?PHP WooThemes_Sensei_Utils::add_user_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WooThemes_Sensei_Utils的用法示例。


在下文中一共展示了WooThemes_Sensei_Utils::add_user_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save_user_answers_feedback

 /**
  * Save the user's answers feedback
  *
  * For this function you must supply all three parameters. If will return false one is left out.
  * The data will be saved on the lesson ID supplied.
  *
  * @since 1.7.5
  * @access public
  *
  * @param array $answers_feedback{
  *  $type int $question_id
  *  $type string $question_feedback
  * }
  * @param int $lesson_id
  * @param int $user_id
  *
  * @return false or int $feedback_saved
  */
 public function save_user_answers_feedback($answers_feedback, $lesson_id, $user_id = 0)
 {
     // make sure the parameters are valid before continuing
     if (empty($lesson_id) || empty($user_id) || 'lesson' != get_post_type($lesson_id) || !get_userdata($user_id) || !is_array($answers_feedback)) {
         return false;
     }
     global $woothemes_sensei;
     // check if the lesson is started before saving, if not start the lesson for the user
     if (!(0 < intval(WooThemes_Sensei_Utils::user_started_lesson($lesson_id, $user_id)))) {
         WooThemes_Sensei_Utils::sensei_start_lesson($lesson_id, $user_id);
     }
     // encode the feedback
     $encoded_answers_feedback = array();
     foreach ($answers_feedback as $question_id => $feedback) {
         $encoded_answers_feedback[$question_id] = base64_encode($feedback);
     }
     // save the user data
     $feedback_saved = WooThemes_Sensei_Utils::add_user_data('quiz_answers_feedback', $lesson_id, $encoded_answers_feedback, $user_id);
     //Were the the question feedback save correctly?
     if (intval($feedback_saved) > 0) {
         // save transient to make retrieval faster in future
         $transient_key = 'sensei_answers_feedback_' . $user_id . '_' . $lesson_id;
         set_transient($transient_key, $encoded_answers_feedback, 10 * DAY_IN_SECONDS);
     }
     return $feedback_saved;
 }
开发者ID:mattytemple,项目名称:YTC-Sensei,代码行数:44,代码来源:class-woothemes-sensei-quiz.php


注:本文中的WooThemes_Sensei_Utils::add_user_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。