當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。