Skip to content

Developer Guide

This page lists the extension points, helper functions, and stored data the plugin uses. All symbols are taken from the plugin source.

The plugin registers no shortcodes and no REST endpoints. It has no settings page of its own; its options live on the BuddyPress member type and profile field screens.

Filter Where Purpose
buddypress_member_type_registration_member_types buddypress_member_type_get_registration_member_types() Filter the member types offered in the registration and profile field options.
bp_member_type_get_site_roles Buddypress_Member_Type_Admin::get_bp_member_type_site_roles() Filter the list of editable site roles used for member type role mapping.
bp_member_types_admin_role_remove Add and Edit views Return false to keep the Administrator role in the Associated Roles dropdown. Default true removes it.
bp_member_type_remove_membertype_metabox bp_member_type_remove_membertype_metabox() Return false to keep BuddyPress’s own member type metabox on the admin edit-user profile screen. Default true removes it when a single-selection field exists.
bp_member_types_count Legacy directory tabs Filter the member count shown on a directory tab.
bp_member_type_get_xprofile_field_id_by_type bp_member_type_get_xprofile_field_id_by_type() Filter the resolved xProfile field id for a given field type.
Action Fired in Notes
bp_member_type_change_user_role bp_member_type_change_user_role() Fires after a user’s role is changed. Passes the user id and the array of role slugs.
bp_member_type_meta_field_display Field Display Control metabox Fires inside the metabox, after the checkbox. Passes the xProfile field object.
bp_member_type_xprofile_save_field bp_member_type_xprofile_save_field() Fires after the field’s show/hide meta is saved.
bp_xprofile_field_type_member_types Multi field constructor Fires when the Member Types (checkbox) field type is constructed.
bp_xprofile_field_type_member_types_radio Single field constructor Fires when the Member Type (radio) field type is constructed.

For reference, these are the BuddyPress hooks the plugin consumes:

  • bp_get_member_type_tax_labels, bp_get_type_metadata_schema (register the per-type display flags)
  • bp_member_type_add_form_fields, bp_member_type_edit_form_fields (Associated Roles field)
  • bp_type_inserted, bp_type_updated (save the role and directory-exclusion data)
  • bp_members_admin_user_metaboxes, xprofile_field_after_sidebarbox, xprofile_fields_saved_field
  • bp_xprofile_get_field_types (register the two field types)
  • bp_set_member_type, xprofile_data_after_save (two-way sync of type and role)
  • bp_after_has_members_parse_args, bp_members_directory_member_types, bp_nouveau_get_members_directory_nav_items (directory tabs and exclusion)
  • bp_core_signup_after_activate (apply role after activation)
  • bp_custom_profile_edit_fields (hide the field on the edit screen when configured)
  • load-users.php (bulk type change)

bp_member_type_get_xprofile_field_id_by_type( $field_type = 'member_types' ) Returns the id of the first xProfile field whose type matches $field_type (member_types or member_type_radio), or null if none exists.

bp_member_type_change_user_role( $user_id, $role_slugs = array() ) Changes a user’s role from an array of role slugs. Assigns all roles when User Role Editor is active, otherwise the single role with the most capabilities. Skips Administrator users. Returns true on success or a WP_Error on invalid input.

buddypress_member_type_get_registration_member_types() Returns the member types available for the current context, filtered by the per-type registration and profile-settings flags.

Option Type Set by
buddypress_member_types_exclude_from_members_directoy array Rebuilt when a member type is saved. Holds the types excluded from the directory. Note: the option name contains the misspelling directoy as shipped.
bp_member_type_update_member_field_enable boolean One-time flag set on admin_init to enable the show-in-profile meta for an existing setup.
Meta key Purpose
bp_member_type_associated_roles The WordPress role slug mapped to this type.
bp_member_type_show_in_registration Whether the type appears in the registration form.
bp_member_type_profile_creation Whether the type is pre-selected on registration.
bp_member_type_show_in_profile_settings Whether the type appears in edit-profile settings.
bp_member_type_exclude_from_members_directoy Whether the type is excluded from the directory. Note the directoy spelling as shipped.
Meta key Purpose
show_hide_member_type Whether the member type field is shown on the front-end profile. Value 1 means shown.