本文整理汇总了PHP中WooThemes_Sensei_Utils::sensei_activity_ids方法的典型用法代码示例。如果您正苦于以下问题:PHP WooThemes_Sensei_Utils::sensei_activity_ids方法的具体用法?PHP WooThemes_Sensei_Utils::sensei_activity_ids怎么用?PHP WooThemes_Sensei_Utils::sensei_activity_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WooThemes_Sensei_Utils
的用法示例。
在下文中一共展示了WooThemes_Sensei_Utils::sensei_activity_ids方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sensei_update_users_certificate_data
/**
* sensei_update_users_certificate_data install user certificate data
* @since 1.0.0
* @param int $n number of items to iterate through
* @param int $offeset number to offset iteration by
* @return boolean
*/
function sensei_update_users_certificate_data($n = 5, $offset = 0)
{
$loop_ran = false;
// Calculate if this is the last page
if (0 == $offset) {
$current_page = 1;
} else {
$current_page = intval($offset / $n);
}
// End If Statement
$args_array = array('number' => $n, 'offset' => $offset, 'orderby' => 'ID', 'order' => 'DESC', 'fields' => 'all_with_meta');
$wp_user_update = new WP_User_Query($args_array);
$users = $wp_user_update->get_results();
$user_count = count_users();
$total_items = $user_count['total_users'];
$query_total = $wp_user_update->get_total();
$total_pages = intval($total_items / $n);
foreach ($users as $user_key => $user_item) {
$course_ids = WooThemes_Sensei_Utils::sensei_activity_ids(array('user_id' => $user_item->ID, 'type' => 'sensei_course_start'));
$posts_array = array();
if (0 < intval(count($course_ids))) {
$posts_array = Sensei()->course->course_query(-1, 'usercourses', $course_ids);
}
// End If Statement
foreach ($posts_array as $course_item) {
$course_end_date = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $course_item->ID, 'user_id' => $user_item->ID, 'type' => 'sensei_course_end', 'field' => 'comment_date'));
if (isset($course_end_date) && '' != $course_end_date) {
$args = array('post_type' => 'certificate', 'author' => $user_item->ID, 'meta_key' => 'course_id', 'meta_value' => $course_item->ID);
$query = new WP_Query($args);
if (!$query->have_posts()) {
// Insert custom post type
$cert_args = array('post_author' => intval($user_item->ID), 'post_title' => esc_html(substr(md5($course_item->ID . $user_item->ID), -8)), 'post_name' => esc_html(substr(md5($course_item->ID . $user_item->ID), -8)), 'post_type' => 'certificate', 'post_status' => 'publish');
$post_id = wp_insert_post($cert_args, $wp_error = false);
if (!is_wp_error($post_id)) {
add_post_meta($post_id, 'course_id', intval($course_item->ID));
add_post_meta($post_id, 'learner_id', intval($user_item->ID));
add_post_meta($post_id, 'certificate_hash', esc_html(substr(md5($course_item->ID . $user_item->ID), -8)));
$loop_ran = true;
}
// End If Statement
}
// End If Statement
wp_reset_query();
}
// End If Statement
}
// End For Loop
}
// End For Loop
if ($current_page >= $total_pages) {
return true;
} else {
return false;
}
// End If Statement
}