本文整理匯總了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;
}