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


PHP stdClass::get_data方法代码示例

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


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

示例1: user_loggedin

 /**
  * Triggered via the user_loggedin event, when a user logs in.
  *
  * @param stdClass $event
  */
 public static function user_loggedin($event)
 {
     global $DB;
     $eventdata = $event->get_data();
     if (!enrol_is_enabled('auto')) {
         return;
     }
     if (is_siteadmin($eventdata['userid'])) {
         // Don't enrol site admins
         return;
     }
     // Get all courses that have an auto enrol plugin, set to auto enrol on login, where the user isn't enrolled yet
     $sql = "SELECT e.courseid\n            FROM {enrol} e\n            LEFT JOIN {user_enrolments} ue ON e.id = ue.enrolid AND ue.userid = ?\n            WHERE e.enrol = 'auto'\n            AND e.status = ?\n            AND e.customint3 = ?\n            AND ue.id IS NULL";
     if (!($courses = $DB->get_records_sql($sql, array($eventdata['userid'], ENROL_INSTANCE_ENABLED, ENROL_AUTO_LOGIN)))) {
         return;
     }
     $autoplugin = enrol_get_plugin('auto');
     foreach ($courses as $course) {
         if (!($instance = $autoplugin->get_instance_for_course($course->courseid))) {
             continue;
         }
         $autoplugin->enrol_user($instance, $eventdata['userid'], $instance->roleid);
         // Send welcome message.
         if ($instance->customint2) {
             $autoplugin = enrol_get_plugin('auto');
             $autoplugin->email_welcome_message($instance, $DB->get_record('user', array('id' => $eventdata['userid'])));
         }
     }
 }
开发者ID:ninelanterns,项目名称:scaffold-enrol_auto,代码行数:34,代码来源:observer.php

示例2: add_rest_api_support_for_post_meta

 /**
  * Add post meta to REST API response.
  *
  * @since 1.0.0
  *
  * @param stdClass        $response Default API response object.
  * @param WP_Post         $post     Current post.
  * @param WP_REST_Request $request  Current API request.
  *
  * @return stdClass $response Updated response request.
  */
 public function add_rest_api_support_for_post_meta($response, $post, $request)
 {
     // Get initial response data.
     $response_data = $response->get_data();
     // Get post meta based on settings.
     $post_meta = get_post_custom($post->ID);
     $post_meta_checked = $this->get_post_meta_checked();
     $response_post_meta = array_intersect_key($post_meta, $post_meta_checked);
     // Add post meta to response data.
     $response_data = array_merge($response_data, $response_post_meta);
     // Re-assemble response.
     $response->set_data($response_data);
     return $response;
 }
开发者ID:leshuis,项目名称:testwp,代码行数:25,代码来源:class-rest-api-enabler.php


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