Last active
August 29, 2015 14:09
-
-
Save bappi-d-great/7e6806f04707aa2d4f79 to your computer and use it in GitHub Desktop.
Shortcode to show instructor lists in WPMU coursepress pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* use [get_all_instructors] | |
* Change wp-content/plugins/ to correct plugins folder if you use a separate folder for plugins at line 9 | |
*/ | |
add_shortcode( 'get_all_instructors', 'get_all_instructors_cb' ); | |
function get_all_instructors_cb() { | |
include ABSPATH . 'wp-content/plugins/coursepress/includes/classes/class.instructorsearch.php'; | |
if ( isset( $_GET['page_num'] ) ) { | |
$page_num = ( int ) $_GET['page_num']; | |
} else { | |
$page_num = 1; | |
} | |
if ( isset( $_GET['s'] ) ) { | |
$usersearch = $_GET['s']; | |
} else { | |
$usersearch = ''; | |
} | |
$wp_user_search = new Instructor_Search( $usersearch, $page_num ); | |
$html = '<table class="instructor_list" width="100%">'; | |
$html .= '<tr>'; | |
$html .= '<th>Username</th>'; | |
$html .= '<th>First Name</th>'; | |
$html .= '<th>Surname</th>'; | |
$html .= '<th>Registered</th>'; | |
$html .= '<th>Courses</th>'; | |
$html .= '</tr>'; | |
foreach ( $wp_user_search->results as $user ) { | |
$user_object = new Instructor( $user->data->ID ); | |
$html .= '<tr>'; | |
$html .= '<td>'.$user_object->user_login.'</td>'; | |
$html .= '<td>'.$user_object->first_name.'</td>'; | |
$html .= '<td>'.$user_object->last_name.'</td>'; | |
$html .= '<td>'.$user_object->user_registered.'</td>'; | |
$html .= '<td>'.$user_object->courses_number.'</td>'; | |
$html .= '</tr>'; | |
} | |
$html .= '</table>'; | |
$html .= '<style>.instructor_list td, .instructor_list th{width: 20% !important; text-align:center}</style>'; | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment