[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress Members Admin 4 * 5 * @package BuddyPress 6 * @subpackage MembersAdmin 7 * @since 2.0.0 8 */ 9 10 // Exit if accessed directly. 11 defined( 'ABSPATH' ) || exit; 12 13 /** 14 * Is the Admin User's community profile enabled? 15 * 16 * @since 10.0.0 17 * 18 * @return bool True if enabled. False otherwise. 19 */ 20 function bp_members_is_community_profile_enabled() { 21 /** 22 * Filter here to disable the Admin User's Community profile. 23 * 24 * @since 10.0.0 25 * 26 * @param bool $value By default the Admin User's Community profile is enabled. 27 */ 28 return apply_filters( 'bp_members_is_community_profile_enabled', true ); 29 } 30 31 // Load the BP Members admin. 32 add_action( 'bp_init', array( 'BP_Members_Admin', 'register_members_admin' ) ); 33 34 /** 35 * Create Users submenu to manage BuddyPress types. 36 * 37 * @since 7.0.0 38 */ 39 function bp_members_type_admin_menu() { 40 if ( ! bp_is_root_blog() ) { 41 return; 42 } 43 44 if ( bp_is_network_activated() && ! bp_is_multiblog_mode() && is_network_admin() ) { 45 // Adds a users.php submenu to go to the root blog Member types screen. 46 $member_type_admin_url = add_query_arg( 'taxonomy', bp_get_member_type_tax_name(), get_admin_url( bp_get_root_blog_id(), 'edit-tags.php' ) ); 47 48 add_submenu_page( 49 'users.php', 50 __( 'Member Types', 'buddypress' ), 51 __( 'Member Types', 'buddypress' ), 52 'bp_moderate', 53 esc_url( $member_type_admin_url ) 54 ); 55 56 } elseif ( ! is_network_admin() ) { 57 add_submenu_page( 58 'users.php', 59 __( 'Member Types', 'buddypress' ), 60 __( 'Member Types', 'buddypress' ), 61 'bp_moderate', 62 basename( add_query_arg( 'taxonomy', bp_get_member_type_tax_name(), bp_get_admin_url( 'edit-tags.php' ) ) ) 63 ); 64 } 65 } 66 add_action( 'bp_admin_menu', 'bp_members_type_admin_menu' ); 67 68 /** 69 * Checks whether a member type already exists. 70 * 71 * @since 7.0.0 72 * 73 * @param boolean $exists True if the member type already exists. False otherwise. 74 * @param string $type_id The member type identifier. 75 * @return bool True if the member type already exists. False otherwise. 76 */ 77 function bp_members_type_admin_type_exists( $exists = false, $type_id = '' ) { 78 if ( ! $type_id ) { 79 return $exists; 80 } 81 82 return ! is_null( bp_get_member_type_object( $type_id ) ); 83 } 84 add_filter( bp_get_member_type_tax_name() . '_check_existing_type', 'bp_members_type_admin_type_exists', 1, 2 ); 85 86 /** 87 * Set the feedback messages for the Member Types Admin actions. 88 * 89 * @since 7.0.0 90 * 91 * @param array $messages The feedback messages. 92 * @return array The feedback messages including the ones for the Member Types Admin actions. 93 */ 94 function bp_members_type_admin_updated_messages( $messages = array() ) { 95 $type_taxonomy = bp_get_member_type_tax_name(); 96 97 $messages[ $type_taxonomy ] = array( 98 0 => '', 99 1 => __( 'Please define the Member Type ID field.', 'buddypress' ), 100 2 => __( 'Member type successfully added.', 'buddypress' ), 101 3 => __( 'Sorry, there was an error and the Member type wasn’t added.', 'buddypress' ), 102 // The following one needs to be != 5. 103 4 => __( 'Member type successfully updated.', 'buddypress' ), 104 5 => __( 'Sorry, this Member type already exists.', 'buddypress' ), 105 6 => __( 'Sorry, the Member type was not deleted: it does not exist.', 'buddypress' ), 106 7 => __( 'Sorry, This Member type is registered using code, deactivate the plugin or remove the custom code before trying to delete it again.', 'buddypress' ), 107 8 => __( 'Sorry, there was an error while trying to delete this Member type.', 'buddypress' ), 108 9 => __( 'Member type successfully deleted.', 'buddypress' ), 109 10 => __( 'Member type could not be updated due to missing required information.', 'buddypress' ), 110 ); 111 112 return $messages; 113 } 114 add_filter( 'term_updated_messages', 'bp_members_type_admin_updated_messages' ); 115 116 /** 117 * Formats xprofile field data about a signup/membership request for display. 118 * 119 * Operates recursively on arrays, which are then imploded with commas. 120 * 121 * @since 10.0.0 122 * 123 * @param string|array $value Field value. 124 */ 125 function bp_members_admin_format_xprofile_field_for_display( $value ) { 126 if ( is_array( $value ) ) { 127 $value = array_map( 'bp_members_admin_format_xprofile_field_for_display', $value ); 128 $value = implode( ', ', $value ); 129 } else { 130 $value = stripslashes( $value ); 131 $value = esc_html( $value ); 132 } 133 134 return $value; 135 } 136 137 /** 138 * Outputs Informations about a signup/membership request into a modal inside the Signups Admin Screen. 139 * 140 * @since 10.0.0 141 * 142 * @param array $signup_field_labels The Signup field labels. 143 * @param object|null $signup_object The signup data object. 144 */ 145 function bp_members_admin_preview_signup_profile_info( $signup_field_labels = array(), $signup_object = null ) { 146 147 ?> 148 <div id="signup-info-modal-<?php echo $signup_object->id; ?>" style="display:none;"> 149 <h1><?php printf( '%1$s (%2$s)', esc_html( $signup_object->user_name ), esc_html( $signup_object->user_email ) ); ?></h1> 150 151 <?php if ( bp_is_active( 'xprofile' ) && isset( $signup_object->meta ) && $signup_field_labels ) : 152 // Init ids. 153 $profile_field_ids = array(); 154 155 // Get all xprofile field IDs except field 1. 156 if ( ! empty( $signup_object->meta['profile_field_ids'] ) ) { 157 $profile_field_ids = array_flip( explode( ',', $signup_object->meta['profile_field_ids'] ) ); 158 unset( $profile_field_ids[1] ); 159 } 160 ?> 161 <h2><?php esc_html_e( 'Extended Profile Information', 'buddypress' ); ?></h2> 162 163 <table class="signup-profile-data-drawer wp-list-table widefat fixed striped"> 164 <?php if ( 1 <= count( $profile_field_ids ) ): foreach ( array_keys( $profile_field_ids ) as $profile_field_id ) : 165 $field_value = isset( $signup_object->meta[ "field_{$profile_field_id}" ] ) ? $signup_object->meta[ "field_{$profile_field_id}" ] : ''; ?> 166 <tr> 167 <td class="column-fields"><?php echo esc_html( $signup_field_labels[ $profile_field_id ] ); ?></td> 168 <td><?php echo bp_members_admin_format_xprofile_field_for_display( $field_value ); ?></td> 169 </tr> 170 <?php endforeach; else: ?> 171 <tr> 172 <td><?php esc_html_e( 'There is no additional information to display.', 'buddypress' ); ?></td> 173 </tr> 174 <?php endif; ?> 175 </table> 176 <?php endif; ?> 177 178 <?php if ( bp_members_site_requests_enabled() ) : ?> 179 <h2><?php esc_html_e( 'Site Request Information', 'buddypress' ); ?></h2> 180 <table class="signup-profile-data-drawer wp-list-table widefat fixed striped"> 181 <?php if ( ! empty( $signup_object->domain ) || ! empty( $signup_object->path ) ) : ?> 182 <tr> 183 <td class="column-fields"><?php esc_html_e( 'Site Title', 'buddypress' ); ?></td> 184 <td><?php echo esc_html( $signup_object->title ); ?></td> 185 </tr> 186 <tr> 187 <td class="column-fields"><?php esc_html_e( 'Domain', 'buddypress' ); ?></td> 188 <td><?php echo esc_html( $signup_object->domain ); ?></td> 189 </tr> 190 <tr> 191 <td class="column-fields"><?php esc_html_e( 'Path', 'buddypress' ); ?></td> 192 <td><?php echo esc_html( $signup_object->path ); ?></td> 193 </tr> 194 <?php else : ?> 195 <tr> 196 <td><?php esc_html_e( 'This user has not requested a blog.', 'buddypress' ); ?></td> 197 </tr> 198 <?php endif; ?> 199 </table> 200 <?php endif; ?> 201 </div> 202 <?php 203 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:57 2024 | Cross-referenced by PHPXref 0.7.1 |