diff --git a/css/pmpro-member-directory.css b/css/pmpro-member-directory.css index 296c18b..58c314c 100644 --- a/css/pmpro-member-directory.css +++ b/css/pmpro-member-directory.css @@ -1,9 +1,15 @@ /* CSS Document */ +form.pmpro_member_directory_search { + align-items: center; + display: flex; + flex-direction: row; + gap: var(--pmpro--base--spacing--small); + justify-content: flex-end; -h2#pmpro_member_directory_subheading {clear: none; margin-top: 0; } -form.pmpro_member_directory_search {float: right; margin-bottom: 1rem; clear: both; } -form.pmpro_member_directory_search input[type=text] { } -form.pmpro_member_directory_search input[type=submit] {background: none; border: none; padding: 0; position: absolute; text-indent: -9999em; } + .pmpro_form_submit { + margin: 0; + } +} .pmpro_member_directory {clear: both; } .pmpro_pagination {margin: 1em 0;} @@ -24,51 +30,87 @@ div.pmpro_member_profile strong {display: block; } .pmpro_member_directory.pmpro_member_directory-2col, .pmpro_member_directory.pmpro_member_directory-3col, .pmpro_member_directory.pmpro_member_directory-4col { - display: grid; - grid-column-gap: 2.9rem; - grid-row-gap: 5.8rem; - text-align: center; + display: grid; + grid-column-gap: 2.9rem; + grid-row-gap: 2.9rem; + + .pmpro_card { + margin: 0; + + .pmpro_card_title a { + text-decoration: none; + } + .pmpro_card_title a:hover { + text-decoration: underline; + } + + .pmpro_card_title.pmpro_heading-avatar-right { + flex-direction: row-reverse; + justify-content: space-between; + } + .pmpro_card_title.pmpro_heading-avatar-top { + align-items: flex-start; + flex-direction: column; + } + .pmpro_card_content { + display: flex; + flex-direction: column; + gap: var(--pmpro--base--spacing--small); + } + + .pmpro_card_actions { + margin-top: auto; + } + } } .pmpro_member_directory.pmpro_member_directory-2col { - grid-template-columns: 1fr 1fr; + grid-template-columns: 1fr 1fr; } .pmpro_member_directory.pmpro_member_directory-3col { - grid-template-columns: 1fr 1fr 1fr; + grid-template-columns: 1fr 1fr 1fr; } .pmpro_member_directory.pmpro_member_directory-4col { - grid-template-columns: 1fr 1fr 1fr 1fr; + grid-template-columns: 1fr 1fr 1fr 1fr; } /* single directory item in list */ .pmpro_member_directory .pmpro_member_directory-item, .pmpro_member_directory .pmpro_member_directory_row { - word-break: break-word; + word-break: break-word; } .pmpro_member_directory_link { - word-break: normal; + word-break: normal; } /* single profile item */ -.pmpro_member_profile { } +.pmpro_member_profile { + + .pmpro_card_content { + display: flex; + flex-direction: column; + gap: var(--pmpro--base--spacing--medium); + margin-top: var(--pmpro--base--spacing--medium); + } +} .pmpro_member_profile .pmpromd_filename { - display: block; + display: block; } @media only screen and (max-width: 767px) { - .pmpro_member_directory.pmpro_member_directory-2col, - .pmpro_member_directory.pmpro_member_directory-3col, - .pmpro_member_directory.pmpro_member_directory-4col { - grid-template-columns: 1fr; - } + .pmpro_member_directory.pmpro_member_directory-2col, + .pmpro_member_directory.pmpro_member_directory-3col, + .pmpro_member_directory.pmpro_member_directory-4col { + grid-template-columns: 1fr; + } } /** * Pagination/page numbers */ .pmpro_page_numbers a { - padding: 6px; + padding: 6px; } .pmpro_page_numbers a.pmpro_page_active { - font-weight: bold; + font-weight: bold; } \ No newline at end of file diff --git a/templates/directory.php b/templates/directory.php index e51191d..f90c4df 100644 --- a/templates/directory.php +++ b/templates/directory.php @@ -10,7 +10,7 @@ function pmpromd_shortcode($atts, $content=null, $code="") // examples: [pmpro_member_directory show_avatar="false" show_email="false" levels="1,2"] extract(shortcode_atts(array( - 'avatar_size' => '128', + 'avatar_size' => '64', 'fields' => NULL, 'layout' => 'div', 'level' => NULL, @@ -167,196 +167,394 @@ function pmpromd_shortcode($atts, $content=null, $code="") $user_identifier = pmpromd_user_identifier(); ob_start(); - ?> - - - - -

- - - %s.','pmpro-member-directory'), stripslashes( ucwords(esc_html($s)))); ?> - - - - 0) { ?> - - () - +
+ + -

- "> + + + %s.','pmpro-member-directory'), stripslashes( ucwords(esc_html($s)))); ?> + + + + 0) { ?> + + () + + + + + options)) - $rh_fields[$field->name] = $field->options; + else + $fields_array = false; + + + /** + * Allow filtering the fields to include on the member directory list. + * + * @since TBD + * + * @param array $fields_array The list of fields to include. + */ + $fields_array = apply_filters( 'pmpro_member_directory_fields', $fields_array ); + + // Get Register Helper field options + $rh_fields = array(); + if(!empty($pmprorh_registration_fields)) { + foreach($pmprorh_registration_fields as $location) { + foreach($location as $field) { + if(!empty($field->options)) + $rh_fields[$field->name] = $field->options; + } } } - } - ?> + ?> - $avatar_size, - 'fields' => $fields, - 'layout' => $layout, - 'level' => $level, - 'levels' => $levels, - 'limit' => $limit, - 'link' => $link, - 'order_by' => $order_by, - 'order' => $order, - 'show_avatar' => $show_avatar, - 'show_email' => $show_email, - 'show_level' => $show_level, - 'show_search' => $show_search, - 'show_startdate' => $show_startdate, - 'avatar_align' => $avatar_align, - 'fields_array' => $fields_array - ) ); - - do_action( 'pmpro_member_directory_before', $sqlQuery, $shortcode_atts ); ?> - -
+ $avatar_size, + 'fields' => $fields, + 'layout' => $layout, + 'level' => $level, + 'levels' => $levels, + 'limit' => $limit, + 'link' => $link, + 'order_by' => $order_by, + 'order' => $order, + 'show_avatar' => $show_avatar, + 'show_email' => $show_email, + 'show_level' => $show_level, + 'show_search' => $show_search, + 'show_startdate' => $show_startdate, + 'avatar_align' => $avatar_align, + 'fields_array' => $fields_array + ) ); + + do_action( 'pmpro_member_directory_before', $sqlQuery, $shortcode_atts ); ?> - - - - - - - - - - - - - - - - - - - - - - - - +
+ + +
+
+
- - - - - - - - - - - -  
+ + + + + + + + + + + + + + + + + + + + + + + ID); + $auser->membership_level = pmpro_getMembershipLevelForUser($auser->ID); + $user_fields_array = pmpromd_filter_profile_fields_for_levels( $fields_array, $auser ); + $count++; + ?> + "> + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +  
+ + ID, $avatar_size, NULL, $auser->user_nicename ); ?> + + ID, $avatar_size, NULL, $auser->user_nicename ); ?> + + + + + + + + + + + user_email, 'user_email' ); ?> + + {$field[1]}; + if(!empty($meta_field)) + { + ?> +
+ + + + $value) + $meta_field[$key] = $rh_fields[$field[1]][$value]; + } + ?> + + + + + + + + {$field[1]}, $field[1] ); ?> + +
+ +
+ ID ); + $membership_levels = array(); + if ( ! isset( $levels ) ) { + // Show all the user's levels. + foreach ( $alluserlevels as $curlevel ) { + $membership_levels[] = $curlevel->name; + } + } else { + $levels_array = explode(',', $levels); + // Show only the levels included in the directory. + foreach ( $alluserlevels as $curlevel ) { + if ( in_array( $curlevel->id, $levels_array) ) { + $membership_levels[] = $curlevel->name; + } + } + } + $auser->membership_levels = implode( ', ', $membership_levels ); + echo ! empty( $auser->membership_levels ) ? $auser->membership_levels : ''; + ?> + + startdate < $min_startdate ) { + $min_startdate = $level->startdate; + } + } + echo ! empty( $min_startdate ) ? date_i18n( get_option( 'date_format' ), $min_startdate ) : ''; + ?> +
+
+ ID); + } + else + { + foreach($theusers as $auser): + $auser = get_userdata($auser->ID); $auser->membership_level = pmpro_getMembershipLevelForUser($auser->ID); + $user_identifier = pmpromd_user_identifier(); $user_fields_array = pmpromd_filter_profile_fields_for_levels( $fields_array, $auser ); - $count++; ?> - "> - - - - ID, $avatar_size, NULL, $auser->user_nicename ); ?> - - ID, $avatar_size, NULL, $auser->user_nicename ); ?> - - - - -

- - +
+ +

+ + + ID, $avatar_size, NULL, $auser->display_name); ?> - + ID, $avatar_size, NULL, $auser->display_name); ?> -

- - - - user_email, 'user_email' ); ?> - - - - - + + + + + +

+
+ +
+ + user_email, 'user_email' ); ?> +
+ + +
+ + ID ); + $membership_levels = array(); + if ( ! isset( $levels ) ) { + // Show all the user's levels. + foreach ( $alluserlevels as $curlevel ) { + $membership_levels[] = $curlevel->name; + } + } else { + $levels_array = explode(',', $levels); + // Show only the levels included in the directory. + foreach ( $alluserlevels as $curlevel ) { + if ( in_array( $curlevel->id, $levels_array) ) { + $membership_levels[] = $curlevel->name; + } + } + } + $auser->membership_levels = implode( ', ', $membership_levels ); + echo ! empty( $auser->membership_levels ) ? $auser->membership_levels : ''; + ?> +
+ + +
+ + membership_level->startdate); ?> +
+ + -

+

- - - + + + + ?> {$field[1]}, $field[1] ); ?> - -

+
- - - - - ID ); - $membership_levels = array(); - if ( ! isset( $levels ) ) { - // Show all the user's levels. - foreach ( $alluserlevels as $curlevel ) { - $membership_levels[] = $curlevel->name; - } - } else { - $levels_array = explode(',', $levels); - // Show only the levels included in the directory. - foreach ( $alluserlevels as $curlevel ) { - if ( in_array( $curlevel->id, $levels_array) ) { - $membership_levels[] = $curlevel->name; - } - } - } - $auser->membership_levels = implode( ', ', $membership_levels ); - echo ! empty( $auser->membership_levels ) ? $auser->membership_levels : ''; - ?> - - - - - startdate < $min_startdate ) { - $min_startdate = $level->startdate; - } } - echo ! empty( $min_startdate ) ? date_i18n( get_option( 'date_format' ), $min_startdate ) : ''; ?> - +
+ +
+ +
- - - - - - - - - - ID); - $auser->membership_level = pmpro_getMembershipLevelForUser($auser->ID); - $user_identifier = pmpromd_user_identifier(); - $user_fields_array = pmpromd_filter_profile_fields_for_levels( $fields_array, $auser ); - ?> -
- -
- - ID, $avatar_size, NULL, $auser->display_name); ?> - - ID, $avatar_size, NULL, $auser->display_name); ?> - -
- -

- - - - - -

- -

- - user_email, 'user_email' ); ?> -

- - -

- - ID ); - $membership_levels = array(); - if ( ! isset( $levels ) ) { - // Show all the user's levels. - foreach ( $alluserlevels as $curlevel ) { - $membership_levels[] = $curlevel->name; - } - } else { - $levels_array = explode(',', $levels); - // Show only the levels included in the directory. - foreach ( $alluserlevels as $curlevel ) { - if ( in_array( $curlevel->id, $levels_array) ) { - $membership_levels[] = $curlevel->name; - } - } - } - $auser->membership_levels = implode( ', ', $membership_levels ); - echo ! empty( $auser->membership_levels ) ? $auser->membership_levels : ''; - ?> -

- - -

- - membership_level->startdate); ?> -

- - + +
+ {$field[1]}; - if(!empty($meta_field)) - { - ?> -

- - - - $value) - $meta_field[$key] = $rh_fields[$field[1]][$value]; - } - ?> - - - - - - - - {$field[1]}, $field[1] ); ?> - -

- - - - - + do_action( 'pmpro_member_directory_after', $sqlQuery, $shortcode_atts ); + + } + } + else + { + ?> +

+ - - %s.','pmpro-member-directory'), stripslashes( ucwords(esc_html($s))) ); + if(!empty($directory_url)) + { + ?> + + +

+ -

- +

%s.','pmpro-member-directory'), stripslashes( ucwords(esc_html($s))) ); - if(!empty($directory_url)) - { - ?> - - 1 ) { + $query_args = array( + 'ps' => $s, + 'pn' => $pn-1, + 'limit' => $limit, + ); + $query_args = apply_filters( 'pmpromd_pagination_url', $query_args, 'prev' ); + ?> + « + -

- -
- 1 ) { - $query_args = array( - 'ps' => $s, - 'pn' => $pn-1, - 'limit' => $limit, - ); - $query_args = apply_filters( 'pmpromd_pagination_url', $query_args, 'prev' ); + $number_of_pages = $totalrows / $limit; + //Page Numbers ?> - « + - - ID ) ) ) . '" title="' . esc_attr__( 'Previous', 'pmpromd' ) . '">...'; - } + $counter = 0; + if ( empty( $pn ) || $pn != 1 ) { + echo '...'; + } - if( round( $number_of_pages, 0 ) !== 1 && $pn !== 1 ) { - //If there's only one page, no need to show the page numbers - for( $i = $pn; $i <= $number_of_pages; $i++ ){ - if( $counter <= 6 ){ - $query_args = array( - 'ps' => $s, - 'pn' => $i, - 'limit' => $limit, - ); - - if( $i == $pn ){ $active_class = 'class="pmpro_page_active"'; } else { $active_class = ''; } - - echo '' . $i . ''; - } - $counter++; - } - } - ?> - - $end ) { - $query_args = array( - 'ps' => $s, - 'pn' => $pn+1, - 'limit' => $limit, - ); - $query_args = apply_filters( 'pmpromd_pagination_url', $query_args, 'next' ); + if( round( $number_of_pages, 0 ) !== 1 && $pn !== 1 ) { + //If there's only one page, no need to show the page numbers + for( $i = $pn; $i <= $number_of_pages; $i++ ){ + if( $counter <= 6 ){ + $query_args = array( + 'ps' => $s, + 'pn' => $i, + 'limit' => $limit, + ); + + if( $i == $pn ){ $active_class = 'class="pmpro_page_active"'; } else { $active_class = ''; } + + echo '' . $i . ''; + } + $counter++; + } + } ?> - » + -
- + //next + if ( $totalrows > $end ) { + $query_args = array( + 'ps' => $s, + 'pn' => $pn+1, + 'limit' => $limit, + ); + $query_args = apply_filters( 'pmpromd_pagination_url', $query_args, 'next' ); + ?> + » + +
+ - - - - "> + + + + options)){ - $rh_fields[$field->name] = $field->options; + // Get Register Helper field options + $rh_fields = array(); + if(!empty($pmprorh_registration_fields)) { + foreach($pmprorh_registration_fields as $location) { + foreach($location as $field) { + if(!empty($field->options)){ + $rh_fields[$field->name] = $field->options; + } } } } - } + ?> +
+ - ?> - - -
- - - -

- ID, $avatar_size, NULL, $pu->display_name, array("class"=>"alignright")); ?> -

- - display_name) ) { ?> -

- -

- - description) ) { ?> -

- - description; ?> -

- - -

- - user_email, 'user_email' ); ?> -

- - -

- - membership_levels ) ? $pu->membership_levels : ''; ?> -

- - -

- - startdate < $min_startdate ) { - $min_startdate = $level->startdate; + display_name ) ) { + $heading_classes = array(); + $heading_classes[] = 'pmpro_card_title'; + $heading_classes[] = 'pmpro_font-x-large'; + if ( ! empty( $show_avatar ) ) { + $heading_classes[] = 'pmpro_heading-with-avatar'; } - } - echo ! empty( $min_startdate ) ? date_i18n( get_option( 'date_format' ), $min_startdate ) : ''; + $heading_classes = implode( ' ', $heading_classes ); ?> -

- - pmpro_baddress1)) { ?> -

- - pmpro_baddress1; ?>
- pmpro_baddress2)) - echo $pu->pmpro_baddress2 . "
"; - ?> - pmpro_bcity && $pu->pmpro_bstate) { ?> - pmpro_bcity; ?>, pmpro_bstate; ?> pmpro_bzipcode; ?>
- pmpro_bcountry; ?>
+

+ + ID, $avatar_size, NULL, $pu->display_name, array("class"=>"alignright")); ?> + + +

+ +
+ ID, $avatar_size, NULL, $pu->display_name, array("class"=>"alignright")); ?> +
+ +
+ description) ) { ?> +
+ + description; ?> +
-

- - pmpro_bphone)) { ?> -

- - pmpro_bphone); ?> -

- - +
+ + user_email, 'user_email' ); ?> +
+ + +
+ + membership_levels ) ? $pu->membership_levels : ''; ?> +
+ + +
+ + startdate < $min_startdate ) { + $min_startdate = $level->startdate; + } + } + echo ! empty( $min_startdate ) ? date_i18n( get_option( 'date_format' ), $min_startdate ) : ''; + ?> +
+ + pmpro_baddress1)) { ?> +
+ + pmpro_baddress1; ?>
+ pmpro_baddress2)) + echo $pu->pmpro_baddress2 . "
"; + ?> + pmpro_bcity && $pu->pmpro_bstate) { ?> + pmpro_bcity; ?>, pmpro_bstate; ?> pmpro_bzipcode; ?>
+ pmpro_bcountry; ?>
+ +
+ + pmpro_bphone)) { ?> +
+ + pmpro_bphone); ?> +
+ + $field_val; + // Fix for a trailing space in the 'fields' shortcode attribute. + if ( $field[0] === ' ' ) { + break; + } - // If using PMPro 2.10, try use User Field function to display labels. - if ( function_exists( 'pmpro_get_label_for_user_field_value' ) && ! empty( $field_val ) && ! empty( $meta_field ) ) { - $meta_field = pmpro_get_label_for_user_field_value( $field_val, $meta_field ); - } + // Get the field name and value here. + $field_val = $field[1]; + $meta_field = $pu->$field_val; - if(!empty($meta_field)) - { - ?> -

- - - - $value) - $meta_field[$key] = $rh_fields[$field[1]][$value]; - } - ?> - - - - - + ?> +

+ + + $value) + $meta_field[$key] = $rh_fields[$field[1]][$value]; + } + ?> + + + - - + + + + + -

- + - -
-
-
-

- %s', esc_url( $directory_url ), esc_html__( 'View All Members', 'pmpro-member-directory' ) ); - } + ?> + +

+
+ ID === $current_user->ID ) { - // User viewing their own profile. Show an edit profile link if 'Member Profile Edit Page' is set or dashboard access is allowed. - if ( ! empty( get_option( 'pmpro_member_profile_edit_page_id' ) ) ) { - $edit_profile_url = pmpro_url( 'member_profile_edit' ); - } elseif ( ! pmpro_block_dashboard() ) { - $edit_profile_url = admin_url( 'profile.php' ); - } + if ( ! empty( $directory_url ) ) { + $pmpro_member_profile_action_links['view-directory'] = sprintf( '%s', esc_url( $directory_url ), esc_html__( 'View All Members', 'pmpro-member-directory' ) ); + } - if ( ! empty( $edit_profile_url) ) { - $pmpro_member_profile_action_links['edit-profile'] = sprintf( '%s', esc_url( $edit_profile_url ), esc_html__( 'Edit Profile', 'paid-memberships-pro' ) ); - } - } + if ( ! empty( $pu ) && $pu->ID === $current_user->ID ) { + // User viewing their own profile. Show an edit profile link if 'Member Profile Edit Page' is set or dashboard access is allowed. + if ( ! empty( get_option( 'pmpro_member_profile_edit_page_id' ) ) ) { + $edit_profile_url = pmpro_url( 'member_profile_edit' ); + } elseif ( ! pmpro_block_dashboard() ) { + $edit_profile_url = admin_url( 'profile.php' ); + } + + if ( ! empty( $edit_profile_url) ) { + $pmpro_member_profile_action_links['edit-profile'] = sprintf( '%s', esc_url( $edit_profile_url ), esc_html__( 'Edit Profile', 'paid-memberships-pro' ) ); + } + } - /** - * Filter which links are displayed on the single Member Directory Profile page. - * - * @since 1.0 - * - * @param array $pmpro_member_profile_action_links Can be view-directory, edit-profile, or or custom. - * - * @return array $pmpro_member_profile_action_links - */ - $pmpro_member_profile_action_links = apply_filters( 'pmpromd_member_profile_action_links', $pmpro_member_profile_action_links ); - - $allowed_html = array( - 'a' => array ( - 'class' => array(), - 'href' => array(), - 'id' => array(), - 'target' => array(), - 'title' => array(), - ), - ); - echo wp_kses( implode( pmpro_actions_nav_separator(), $pmpro_member_profile_action_links ), $allowed_html ); - ?> -

- + /** + * Filter which links are displayed on the single Member Directory Profile page. + * + * @since 1.0 + * + * @param array $pmpro_member_profile_action_links Can be view-directory, edit-profile, or or custom. + * + * @return array $pmpro_member_profile_action_links + */ + $pmpro_member_profile_action_links = apply_filters( 'pmpromd_member_profile_action_links', $pmpro_member_profile_action_links ); + + $allowed_html = array( + 'a' => array ( + 'class' => array(), + 'href' => array(), + 'id' => array(), + 'target' => array(), + 'title' => array(), + ), + ); + echo wp_kses( implode( pmpro_actions_nav_separator(), $pmpro_member_profile_action_links ), $allowed_html ); + ?> +
+
+ +