本文整理汇总了PHP中ThemexCore::addUserRelation方法的典型用法代码示例。如果您正苦于以下问题:PHP ThemexCore::addUserRelation方法的具体用法?PHP ThemexCore::addUserRelation怎么用?PHP ThemexCore::addUserRelation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThemexCore
的用法示例。
在下文中一共展示了ThemexCore::addUserRelation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getQuestions
/**
* Gets quiz questions
*
* @access public
* @param int $ID
* @return array
*/
public static function getQuestions($ID)
{
$selection = absint(ThemexCore::getPostMeta($ID, 'quiz_selection'));
$questions = themex_filter(ThemexCore::getPostMeta($ID, 'quiz_questions'));
if (!empty($selection) && $selection < count($questions)) {
$keys = ThemexCore::getUserRelations(get_current_user_id(), $ID, 'questions', true);
if (!empty($keys)) {
$keys = explode(',', $keys);
$questions = array_intersect_key($questions, array_flip($keys));
}
if ($selection != count($questions)) {
$questions = themex_shuffle($questions);
$questions = array_slice($questions, 0, $selection);
$keys = implode(',', array_keys($questions));
ThemexCore::addUserRelation(get_current_user_id(), $ID, 'questions', $keys);
}
}
return $questions;
}
示例2: addUser
/**
* Adds course member
*
* @access public
* @param int $ID
* @param bool $private
* @return void
*/
public static function addUser($ID, $user, $private = false)
{
self::refresh($ID);
$redirect = get_permalink($ID);
if ($user != 0 || self::$data['status'] == 'premium' && self::$data['product'] != 0) {
if (!self::isMember($user)) {
if ($private || self::$data['status'] == 'free' || self::$data['status'] == 'premium' && self::$data['product'] == 0) {
ThemexCore::addUserRelation($user, $ID, 'course', current_time('timestamp'));
self::$data['users'][] = $user;
$number = count(self::$data['users']);
ThemexCore::updatePostMeta($ID, 'course_popularity', $number);
$message = ThemexCore::getOption('email_course');
if (!empty($message)) {
$data = get_userdata($user);
$keywords = array('username' => $data->user_login, 'title' => get_the_title($ID), 'link' => $redirect);
themex_mail($data->user_email, __('Course Membership', 'academy'), themex_keywords($message, $keywords));
}
if (!$private) {
wp_redirect($redirect);
exit;
}
} else {
if (self::$data['status'] == 'premium') {
ThemexWoo::addProduct(self::$data['product']);
}
}
} else {
if (!$private) {
wp_redirect($redirect);
exit;
}
}
}
}
示例3: addRelation
/**
* Adds user relation
*
* @access public
* @param int $ID
* @param array $data
* @return void
*/
public static function addRelation($ID, $data)
{
$relation = themex_value('relation_id', $data);
$type = themex_value('relation_type', $data);
if (in_array($type, array('shop', 'product'))) {
ThemexCore::addUserRelation($ID, $relation, $type);
if ($type == 'shop') {
$relations = count(ThemexCore::getUserRelations(0, $relation, 'shop'));
ThemexCore::updatePostMeta($relation, 'admirers', $relations);
}
}
die;
}