llms_make_select2_student_array( array $user_ids = array(), string $template = '' )
Create an array that can be passed to metabox select elements configured as an llms-select2-student query-ier.
Parameters Parameters
- $user_ids
-
(array) (Optional) Indexed array of WordPress User IDs. Default is empty array.
Default value: array()
- $template
-
(string) (Optional) A template to customize the way the results look. Default is empty string.<br> %1$s = student name %2$s = student email.
Default value: ''
Return Return
(array)
Source Source
File: includes/llms.functions.core.php
function llms_make_select2_student_array( $user_ids = array(), $template = '' ) {
if ( ! $template ) {
$template = '%1$s <%2$s>';
}
if ( ! is_array( $user_ids ) ) {
$user_ids = array( $user_ids );
}
$ret = array();
foreach ( $user_ids as $id ) {
$student = llms_get_student( $id );
if ( ! $student ) {
continue;
}
$ret[] = array(
'key' => $id,
'title' => sprintf( $template, $student->get_name(), $student->get( 'user_email' ) ),
);
}
/**
* Filter the select2 student array
*
* @since Unknown
*
* @param array $elements Associative array representing select2 student elements.
* @param array $post_ids Optional. Indexed array of WordPress Post IDs.
*/
return apply_filters( 'llms_make_select2_student_array', $ret, $user_ids );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.10.1 | Introduced. |