/** * Render the xprofile metabox for Community Profile screen. * * @since 2.0.0 * * @param WP_User|null $user The WP_User object for the user being edited. * @param array $args Aray of arguments for metaboxes. */ public function user_admin_profile_metaboxes($user = null, $args = array()) { // Bail if no user ID. if (empty($user->ID)) { return; } $r = bp_parse_args($args['args'], array('profile_group_id' => 0, 'user_id' => $user->ID), 'bp_xprofile_user_admin_profile_loop_args'); // We really need these args. if (empty($r['profile_group_id']) || empty($r['user_id'])) { return; } // Bail if no profile fields are available. if (!bp_has_profile($r)) { return; } // Loop through profile groups & fields. while (bp_profile_groups()) { bp_the_profile_group(); ?> <input type="hidden" name="field_ids[]" id="<?php echo esc_attr('field_ids_' . bp_get_the_profile_group_slug()); ?> " value="<?php echo esc_attr(bp_get_the_profile_group_field_ids()); ?> " /> <?php if (bp_get_the_profile_group_description()) { ?> <p class="description"><?php bp_the_profile_group_description(); ?> </p> <?php } ?> <?php while (bp_profile_fields()) { bp_the_profile_field(); ?> <div<?php bp_field_css_class('bp-profile-field'); ?> > <?php $field_type = bp_xprofile_create_field_type(bp_get_the_profile_field_type()); $field_type->edit_field_html(array('user_id' => $r['user_id'])); if (bp_get_the_profile_field_description()) { ?> <p class="description"><?php bp_the_profile_field_description(); ?> </p> <?php } /** * Fires before display of visibility form elements for profile metaboxes. * * @since 1.7.0 */ do_action('bp_custom_profile_edit_fields_pre_visibility'); $can_change_visibility = bp_current_user_can('bp_xprofile_change_field_visibility'); ?> <p class="field-visibility-settings-<?php echo $can_change_visibility ? 'toggle' : 'notoggle'; ?> " id="field-visibility-settings-toggle-<?php bp_the_profile_field_id(); ?> "> <?php printf(__('This field can be seen by: %s', 'buddypress'), '<span class="current-visibility-level">' . bp_get_the_profile_field_visibility_level_label() . '</span>'); ?> <?php if ($can_change_visibility) { ?> <a href="#" class="button visibility-toggle-link"><?php esc_html_e('Change', 'buddypress'); ?> </a> <?php } ?> </p> <?php if ($can_change_visibility) { ?> <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id(); ?> "> <fieldset> <legend><?php _e('Who can see this field?', 'buddypress'); ?> </legend> <?php bp_profile_visibility_radio_buttons(); ?> </fieldset> <a class="button field-visibility-settings-close" href="#"><?php esc_html_e('Close', 'buddypress'); ?> </a> </div> <?php } ?> <?php /** * Fires at end of custom profile field items on your xprofile screen tab. * * @since 1.1.0 */ do_action('bp_custom_profile_edit_fields'); ?> </div> <?php } // End bp_profile_fields(). ?> <?php } // End bp_profile_groups. }
?> </a> </p> <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id(); ?> "> <fieldset> <legend><?php _e('Who can see this field?', 'buddypress'); ?> </legend> <?php bp_profile_visibility_radio_buttons(); ?> </fieldset> <a class="field-visibility-settings-close" href="#"><?php _e('Close', 'buddypress'); ?> </a> </div> <?php } else { ?> <p class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id(); ?>
function firmasite_profile_field_custom_change_field_visibility() { ?> <p class="description text-muted"><?php bp_the_profile_field_description(); ?> </p> <?php if (bp_current_user_can('bp_xprofile_change_field_visibility')) { ?> <p class="field-visibility-settings-toggle text-muted" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id(); ?> "> <?php printf(__('This field can be seen by: <span class="current-visibility-level">%s</span>', "firmasite"), bp_get_the_profile_field_visibility_level_label()); ?> <a href="#" class="visibility-toggle-link"><?php _e('Change', "firmasite"); ?> </a> </p> <div class="field-visibility-settings well well-sm" id="field-visibility-settings-<?php bp_the_profile_field_id(); ?> "> <fieldset> <legend><?php _e('Who can see this field?', "firmasite"); ?> </legend> <?php bp_profile_visibility_radio_buttons(); ?> </fieldset> <a class="field-visibility-settings-close" href="#"><?php _e('Close', "firmasite"); ?> </a> </div> <?php } else { ?> <div class="field-visibility-settings-notoggle text-muted" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id(); ?> "> <?php printf(__('This field can be seen by: <span class="current-visibility-level">%s</span>', "firmasite"), bp_get_the_profile_field_visibility_level_label()); ?> </div> <?php } ?> <?php do_action('bp_custom_profile_edit_fields'); ?> <?php }
/** * Renders BuddyPress account extra fields. * * @since 3.5 * * @access private */ private function _render_buddypress_account_extra_fields() { if (!bp_is_active('xprofile')) { return; } do_action('bp_before_signup_profile_fields'); ?> <div class="register-section" id="profile-details-section"> <h4><?php _e('Profile Details', 'membership'); ?> </h4> <?php if (bp_has_profile('profile_group_id=1&hide_empty_fields=0')) { ?> <?php while (bp_profile_groups()) { bp_the_profile_group(); ?> <?php while (bp_profile_fields()) { bp_the_profile_field(); ?> <?php $field_name = bp_get_the_profile_field_input_name(); ?> <?php $field_name_esc = esc_attr($field_name); ?> <?php $field_type = bp_get_the_profile_field_type(); ?> <div class="editfield"> <?php if ('textbox' == $field_type) { ?> <label for="<?php echo $field_name_esc; ?> "> <?php if (bp_get_the_profile_field_is_required()) { ?> <?php printf(_x('%s (required)', '{Profile field} (required)', 'membership'), bp_get_the_profile_field_name()); ?> <?php } else { ?> <?php bp_the_profile_field_name(); ?> <?php } ?> </label> <?php do_action("bp_{$field_name}_errors"); ?> <input type="text" name="<?php echo $field_name_esc; ?> " id="<?php echo $field_name_esc; ?> " value="<?php bp_the_profile_field_edit_value(); ?> " /> <?php } ?> <?php if ('textarea' == $field_type) { ?> <label for="<?php echo $field_name_esc; ?> "> <?php if (bp_get_the_profile_field_is_required()) { ?> <?php printf(_x('%s (required)', '{Profile field} (required)', 'membership'), bp_get_the_profile_field_name()); ?> <?php } else { ?> <?php bp_the_profile_field_name(); ?> <?php } ?> </label> <?php do_action("bp_{$field_name}_errors"); ?> <textarea rows="5" cols="40" name="<?php echo $field_name_esc; ?> " id="<?php echo $field_name_esc; ?> "><?php bp_the_profile_field_edit_value(); ?> </textarea> <?php } ?> <?php if ('selectbox' == $field_type) { ?> <label for="<?php echo $field_name_esc; ?> "> <?php if (bp_get_the_profile_field_is_required()) { ?> <?php printf(_x('%s (required)', '{Profile field} (required)', 'membership'), bp_get_the_profile_field_name()); ?> <?php } else { ?> <?php bp_the_profile_field_name(); ?> <?php } ?> </label> <?php do_action("bp_{$field_name}_errors"); ?> <select name="<?php echo $field_name_esc; ?> " id="<?php echo $field_name_esc; ?> "> <?php bp_the_profile_field_options(); ?> </select> <?php } ?> <?php if ('multiselectbox' == $field_type) { ?> <label for="<?php echo $field_name_esc; ?> "> <?php if (bp_get_the_profile_field_is_required()) { ?> <?php printf(_x('%s (required)', '{Profile field} (required)', 'membership'), bp_get_the_profile_field_name()); ?> <?php } else { ?> <?php bp_the_profile_field_name(); ?> <?php } ?> </label> <?php do_action("bp_{$field_name}_errors"); ?> <select name="<?php echo $field_name_esc; ?> " id="<?php echo $field_name_esc; ?> " multiple="multiple"> <?php bp_the_profile_field_options(); ?> </select> <?php } ?> <?php if ('radio' == $field_type) { ?> <div class="radio"> <span class="label"> <?php if (bp_get_the_profile_field_is_required()) { ?> <?php printf(_x('%s (required)', '{Profile field} (required)', 'membership'), bp_get_the_profile_field_name()); ?> <?php } else { ?> <?php bp_the_profile_field_name(); ?> <?php } ?> </span> <?php do_action("bp_{$field_name}_errors"); ?> <?php bp_the_profile_field_options(); ?> <?php if (!bp_get_the_profile_field_is_required()) { ?> <a class="clear-value" href="javascript:clear( '<?php echo $field_name_esc; ?> ' );"><?php _e('Clear', 'membership'); ?> </a> <?php } ?> </div> <?php } ?> <?php if ('checkbox' == $field_type) { ?> <div class="checkbox"> <span class="label"> <?php if (bp_get_the_profile_field_is_required()) { ?> <?php printf(_x('%s (required)', '{Profile field} (required)', 'membership'), bp_get_the_profile_field_name()); ?> <?php } else { ?> <?php bp_the_profile_field_name(); ?> <?php } ?> </span> <?php do_action("bp_{$field_name}_errors"); ?> <?php bp_the_profile_field_options(); ?> </div> <?php } ?> <?php if ('datebox' == $field_type) { ?> <div class="datebox"> <label for="<?php echo $field_name_esc; ?> _day"> <?php if (bp_get_the_profile_field_is_required()) { ?> <?php printf(_x('%s (required)', '{Profile field} (required)', 'membership'), bp_get_the_profile_field_name()); ?> <?php } else { ?> <?php bp_the_profile_field_name(); ?> <?php } ?> </label> <?php do_action("bp_{$field_name}_errors"); ?> <select name="<?php echo $field_name_esc; ?> _day" id="<?php echo $field_name_esc; ?> _day"> <?php bp_the_profile_field_options('type=day'); ?> </select> <select name="<?php echo $field_name_esc; ?> _month" id="<?php echo $field_name_esc; ?> _month"> <?php bp_the_profile_field_options('type=month'); ?> </select> <select name="<?php echo $field_name_esc; ?> _year" id="<?php echo $field_name_esc; ?> _year"> <?php bp_the_profile_field_options('type=year'); ?> </select> </div> <?php } ?> <?php do_action('bp_custom_profile_edit_fields_pre_visibility'); ?> <?php if (bp_current_user_can('bp_xprofile_change_field_visibility')) { ?> <p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id(); ?> "> <?php printf(_x('This field can be seen by: %s', 'This field can be seen by: {Administrator}', 'membership'), '<span class="current-visibility-level">' . bp_get_the_profile_field_visibility_level_label() . '</span>'); ?> <a href="#" class="visibility-toggle-link"><?php _ex('Change', 'Change profile field visibility level', 'membership'); ?> </a> </p> <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id(); ?> "> <fieldset> <legend><?php _e('Who can see this field?', 'membership'); ?> </legend> <?php bp_profile_visibility_radio_buttons(); ?> </fieldset> <a class="field-visibility-settings-close" href="#"><?php _e('Close', 'membership'); ?> </a> </div> <?php } else { ?> <p class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id(); ?> "> <?php printf(__('This field can be seen by: <span class="current-visibility-level">%s</span>', 'membership'), bp_get_the_profile_field_visibility_level_label()); ?> </p> <?php } ?> <?php do_action('bp_custom_profile_edit_fields'); ?> <p class="description"><?php bp_the_profile_field_description(); ?> </p> </div> <?php } ?> <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids(); ?> "> <?php } ?> <?php } ?> </div><!-- #profile-details-section --><?php do_action('bp_after_signup_profile_fields'); }
/** * Generates the HTML code for a single XProfile input field. * * Code is taken from the BuddyPress default theme file: * plugins/buddypress/bp-themes/bp-default/registration/register.php * * @since 1.0.1.0 * @param int $field_id The XProfile field ID. * @param mixed $field_value Value of the field. * @return string The HTML code to display the field. */ public function render_xprofile_field($field_id, $field_value = null, $visibility = false) { global $field; $field = xprofile_get_field($field_id); ob_start(); ?> <div class="ms-form-element ms-form-element-xprofile editfield field-<?php echo $field_id; ?> "> <?php if ('textarea' == bp_get_the_profile_field_type()) { ?> <label for="<?php bp_the_profile_field_input_name(); ?> "><?php bp_the_profile_field_name(); ?> <?php if (bp_get_the_profile_field_is_required()) { _e('(required)', 'buddypress'); } ?> </label> <?php do_action(bp_get_the_profile_field_errors_action()); ?> <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name(); ?> " id="<?php bp_the_profile_field_input_name(); ?> "><?php bp_the_profile_field_edit_value(); ?> </textarea> <?php } elseif ('selectbox' == bp_get_the_profile_field_type()) { ?> <label for="<?php bp_the_profile_field_input_name(); ?> "><?php bp_the_profile_field_name(); ?> <?php if (bp_get_the_profile_field_is_required()) { _e('(required)', 'buddypress'); } ?> </label> <?php do_action(bp_get_the_profile_field_errors_action()); ?> <select name="<?php bp_the_profile_field_input_name(); ?> " id="<?php bp_the_profile_field_input_name(); ?> "> <?php bp_the_profile_field_options(); ?> </select> <?php } elseif ('multiselectbox' == bp_get_the_profile_field_type()) { ?> <label for="<?php bp_the_profile_field_input_name(); ?> "><?php bp_the_profile_field_name(); ?> <?php if (bp_get_the_profile_field_is_required()) { _e('(required)', 'buddypress'); } ?> </label> <?php do_action(bp_get_the_profile_field_errors_action()); ?> <select name="<?php bp_the_profile_field_input_name(); ?> " id="<?php bp_the_profile_field_input_name(); ?> " multiple="multiple"> <?php bp_the_profile_field_options(); ?> </select> <?php } elseif ('radio' == bp_get_the_profile_field_type()) { ?> <div class="radio"> <span class="label"><?php bp_the_profile_field_name(); ?> <?php if (bp_get_the_profile_field_is_required()) { _e('(required)', 'buddypress'); } ?> </span> <?php do_action(bp_get_the_profile_field_errors_action()); ?> <?php bp_the_profile_field_options(); ?> <?php if (!bp_get_the_profile_field_is_required()) { ?> <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name(); ?> ' );"><?php _e('Clear', 'buddypress'); ?> </a> <?php } ?> </div> <?php } elseif ('checkbox' == bp_get_the_profile_field_type()) { ?> <div class="checkbox"> <span class="label"><?php bp_the_profile_field_name(); ?> <?php if (bp_get_the_profile_field_is_required()) { _e('(required)', 'buddypress'); } ?> </span> <?php do_action(bp_get_the_profile_field_errors_action()); ?> <?php bp_the_profile_field_options(); ?> </div> <?php } elseif ('datebox' == bp_get_the_profile_field_type()) { ?> <div class="datebox"> <label for="<?php bp_the_profile_field_input_name(); ?> _day"><?php bp_the_profile_field_name(); ?> <?php if (bp_get_the_profile_field_is_required()) { _e('(required)', 'buddypress'); } ?> </label> <?php do_action(bp_get_the_profile_field_errors_action()); ?> <select name="<?php bp_the_profile_field_input_name(); ?> _day" id="<?php bp_the_profile_field_input_name(); ?> _day"> <?php bp_the_profile_field_options('type=day'); ?> </select> <select name="<?php bp_the_profile_field_input_name(); ?> _month" id="<?php bp_the_profile_field_input_name(); ?> _month"> <?php bp_the_profile_field_options('type=month'); ?> </select> <select name="<?php bp_the_profile_field_input_name(); ?> _year" id="<?php bp_the_profile_field_input_name(); ?> _year"> <?php bp_the_profile_field_options('type=year'); ?> </select> </div> <?php } else { ?> <label for="<?php bp_the_profile_field_input_name(); ?> "><?php bp_the_profile_field_name(); ?> <?php if (bp_get_the_profile_field_is_required()) { _e('(required)', 'buddypress'); } ?> </label> <?php do_action(bp_get_the_profile_field_errors_action()); ?> <input type="<?php bp_the_profile_field_type(); ?> " name="<?php bp_the_profile_field_input_name(); ?> " id="<?php bp_the_profile_field_input_name(); ?> " value="<?php bp_the_profile_field_edit_value(); ?> " /> <?php } ?> <?php if ($visibility) { ?> <?php do_action('bp_custom_profile_edit_fields_pre_visibility'); ?> <?php if (bp_current_user_can('bp_xprofile_change_field_visibility')) { ?> <p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id(); ?> "> <?php printf(__('This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress'), bp_get_the_profile_field_visibility_level_label()); ?> <a href="#" class="visibility-toggle-link"><?php _ex('Change', 'Change profile field visibility level', 'buddypress'); ?> </a> </p> <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id(); ?> "> <fieldset> <legend><?php _e('Who can see this field?', 'buddypress'); ?> </legend> <?php bp_profile_visibility_radio_buttons(); ?> </fieldset> <a class="field-visibility-settings-close" href="#"><?php _e('Close', 'buddypress'); ?> </a> </div> <?php } else { ?> <p class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id(); ?> "> <?php printf(__('This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress'), bp_get_the_profile_field_visibility_level_label()); ?> </p> <?php } ?> <?php } ?> <?php do_action('bp_custom_profile_edit_fields'); ?> <p class="description"><?php bp_the_profile_field_description(); ?> </p> </div> <?php $html = ob_get_clean(); return $html; }
/** * Render the xprofile metabox for Community Profile screen. * * @access public * @since BuddyPress (2.0.0) * * @param WP_User $user The WP_User object for the user being edited. */ public function user_admin_profile_metaboxes($user = null, $args = array()) { if (empty($user->ID)) { return; } $r = bp_parse_args($args['args'], array('profile_group_id' => 0, 'user_id' => $user->ID), 'bp_xprofile_user_admin_profile_loop_args'); // We really need these args if (empty($r['profile_group_id']) || empty($r['user_id'])) { return; } if (bp_has_profile($r)) { while (bp_profile_groups()) { bp_the_profile_group(); ?> <input type="hidden" name="field_ids[]" id="<?php echo esc_attr('field_ids_' . bp_get_the_profile_group_slug()); ?> " value="<?php echo esc_attr(bp_get_the_profile_group_field_ids()); ?> " /> <?php if (bp_get_the_profile_group_description()) { ?> <p class="description"><?php bp_the_profile_group_description(); ?> </p> <?php } while (bp_profile_fields()) { bp_the_profile_field(); ?> <div<?php bp_field_css_class('bp-profile-field'); ?> > <?php $field_type = bp_xprofile_create_field_type(bp_get_the_profile_field_type()); $field_type->edit_field_html(array('user_id' => $r['user_id'])); if (bp_get_the_profile_field_description()) { ?> <p class="description"><?php bp_the_profile_field_description(); ?> </p> <?php } do_action('bp_custom_profile_edit_fields_pre_visibility'); $can_change_visibility = bp_current_user_can('bp_xprofile_change_field_visibility'); ?> <p class="field-visibility-settings-<?php echo $can_change_visibility ? 'toggle' : 'notoggle'; ?> " id="field-visibility-settings-toggle-<?php bp_the_profile_field_id(); ?> "> <?php printf(__('This field can be seen by: <span class="%s">%s</span>', 'buddypress'), esc_attr('current-visibility-level'), bp_get_the_profile_field_visibility_level_label()); if ($can_change_visibility) { ?> <a href="#" class="button visibility-toggle-link"><?php _e('Change', 'buddypress'); ?> </a> <?php } ?> </p> <?php if ($can_change_visibility) { ?> <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id(); ?> "> <fieldset> <legend><?php _e('Who can see this field?', 'buddypress'); ?> </legend> <?php bp_profile_visibility_radio_buttons(); ?> </fieldset> <a class="button field-visibility-settings-close" href="#"><?php _e('Close', 'buddypress'); ?> </a> </div> <?php } do_action('bp_custom_profile_edit_fields'); ?> </div> <?php } // bp_profile_fields() } // bp_profile_groups() } }