本文整理汇总了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'])));
}
}
}
示例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;
}