Notice of Deprecated Functions in 14.0.0


BuddyPress 14.0.0  has deprecated functions and constants that will no longer be supported. Furthermore, these functions and constants may be removed from future versions, therefore it is  recommended to update any code that uses them, appropriately.

FunctionStatusVersion
bp_block_init_editor_settings_filter()Deprecated14.0.0
bp_block_init_category_filter()Deprecated14.0.0
bp_use_wp_admin_bar()Deprecated14.0.0
bp_admin_email_add_codex_notice()Deprecated14.0.0
bp_activity_admin_screen_options( $value, $option, $new_value )Deprecated14.0.0
bp_groups_admin_screen_options( $value, $option, $new_value )Deprecated14.0.0

See src/bp-core/deprecated/14.0.php for further code details.

ConstantStatusVersion
BP_USE_WP_ADMIN_BARDeprecated14.0.0
BP_SIGNUPS_SKIP_USER_CREATIONDeprecated14.0.0

Additional Suggestions:

For non-developers, here are some tips for resolving deprecation notices in BuddyPress:

  • Update themes and plugins: This is the most common fix.
  • If the plugin or theme developer doesn’t have an update available, contact them directly. 

FYI: 14.0.0 schedule

  • June 13: 14.0.0-beta1 ✅.
  • June 24: 14.0.0-beta2 ✅.
  • July 5: 14.0.0-rc1 ✅.
  • July 8 July 12: 14.0.0 ✅.

#14-0-0, #notification

Translating BuddyPress texts into your community vocabulary is back in 14.0.0

Thanks to WordPress 6.5 localization improvements, we’re happy to share with you this great news: customizing BuddyPress texts according to your community site’s purpose is possible again without any additional plugins 😅. Whether you use the default WordPress locale (en_US) or any other ones, you can override it to change all the BuddyPress texts of your choice! Below is an example of my test replacing all “group” terms with “team” ones.

We thought as we made it possible for you to customize any BuddyPress URLs since our previous major version (12.0.0), we had to bring back custom translation files locations (which sadly vanished 😭 when WordPress 4.6 was released, 8 years ago).

We even extended it so that you can also have custom translation files for BuddyPress blocks 👇

If you’re wondering what you’ll have to do to enjoy it, here’s the documentation about it.

You need to view it to believe it? Be my guest: you can beta test it (& contribute to BuddyPress beta testing 😁).

#14-0-0, #translations

Signup fields via the REST API

With the purpose of adding parity between the web version and the REST API, we are introducing a minor breaking change in the next version of BuddyPress (v14.0.0 ) in how the BuddyPress REST API handles Signup XProfile fields.

In this article, I’ll try to explain what the change is, why is necessary, and how you can prepare your app for these changes which will be available when the new BuddyPress version is released.

What problem are we solving?

Currently, our REST API does not support getting Signup XProfile fields or saving them. This means that when creating a signup via the API, there is only one XProfile field available, the user_name argument. This argument is mapped to the required “Name (Primary)” field.

However, if a community administrator creates more custom Signup fields, they would not be able to use them via the REST API. This creates an incomplete experience for API consumers that need to have signup fields in their apps.

As part of the, not yet released, v14.0.0 version, we are changing this behavior. API consumers will be able to return the Signup XProfile fields, and send them while creating a signup via the API. 🥳

Fetch Signup fields

To fetch signup fields only, we introduced a new argument, signup_fields_only. Here is an example of a request to select the Signup group, using the XProfile Groups endpoint:

bp.apiRequest( {
  path: 'buddypress/v1/xprofile/groups',
  type: 'GET',
  data: {
    context: 'view',
    fetch_fields: true // <-- required, in this endpoint.
    signup_fields_only: true // <--- new argument.
  }
} ).done( function( data ) {
  return data; // <--- It returns the signup fields only.
} ).fail( function( error ) {
  return error;
} );

Here is an example of a request to select only the Signup fields, using the XProfile Fields endpoint:

bp.apiRequest( {
  path: 'buddypress/v1/xprofile/fields',
  type: 'GET',
  data: {
    context: 'view',
    signup_fields_only: true // <--- new argument.
  }
} ).done( function( data ) {
  return data; // <--- It returns the signup fields only.
} ).fail( function( error ) {
  return error;
} );

Send signup fields

While creating a signup via the API, a new argument, signup_field_data is required. This argument is mapped to the Signup fields (the order the field data is sent is not important).

bp.apiRequest( {
  path: 'buddypress/v1/signup',
  type: 'POST',
  data: {
    context: 'edit',
    user_login: 'testuser',
    user_email: 'test@user.mail',
    password: 'password' // Always use strong passwords, not like this one!
    "signup_field_data[0][field_id]": "36",
	"signup_field_data[0][value]": "Arabic, English",
	"signup_field_data[1][field_id]": "31",
	"signup_field_data[1][value]": "Sometimes, I never travel",
	"signup_field_data[2][field_id]": "35",
	"signup_field_data[2][value]": "This is some text for my profile.",
	"signup_field_data[3][field_id]": "1",
	"signup_field_data[3][value]": "New Profile",
	"signup_field_data[4][field_id]": "19",
	"signup_field_data[4][value]": "Option 01, Option 03",
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

The most noticeable change is that required fields will be respected in the API now. If you send a request creating a signup without the required fields (or sending empty values for the required fields), the REST API will complain about it, just like the web version.

Here is an example of a failed request without a required field.

{
  "code": "bp_rest_signup_field_required",
  "data": {
    "status": 500
  },
  "message": "The CUSTOM field is required."
}

How to migrate

Now, how can you prepare for this change? If your project makes use of the now deprecated user_name argument, you’ll need to update your app to use the new signup_field_data argument when creating a signup via the REST API.

We haven’t updated our documentation yet with those changes, but here is the schema for the new argument:

"signup_field_data": {
  "description": "The XProfile field data for the new user.",
  "items": {
    "properties": {
      "field_id": {
        "description": "The XProfile field ID.",
        "required": true,
        "type": "integer",
      },
      "value": {
        "default": "",
        "description": "The value(s) (comma separated list of values needs to be used in case of multiple values) for the field data.",
        "required": true,
        "type": "string",
      },
      "visibility": {
        "default": "public",
        "description": "The visibility for the XProfile field.",
        "enum": [
          "public",
          "adminsonly",
          "loggedin",
          "friends"
        ],
        "required": false,
        "type": "string",
      }
    },
    "type": "object"
  },
}

The new field expects an array of data with the field_id, its value, and the visibility of the field.

Why do I need to move my code into the new signup_field_data?

One important goal of this change is to add parity with the web version. Keeping the new and the old argument user_name would defeat this purpose. It would also create unnecessary handling of fallbacks, and ultimately confusion.

A user could send the “Name (Primary)” field via user_name argument or using the new signup_field_data argument. Required fields would also not be truly required. Essentially, creating a lot of code to account for both situations.

It’s also accurate to say that the old behavior is a bug, not a feature (or at the very least an MVP of an MVP of an MVP). We are correcting this bug as part of this change.

=D

#developers, #rest-api

WP CLI BuddyPress – v3.0.0

🎈 A new release of WP CLI BuddyPress, v3.0.0, is now available.

The main purpose of this release was to introduce new commands, and polish the implementation of available commands. As always, you can also skip directly to the detailed changelog if you prefer.

This update will be bundled with BuddyPress core when the v14.0.0 version is released. You can also test the new changes beforehand by following the recommended installation methods.

New Commands

We are introducing a few more commands to the package. Mainly:

wp bp notice

This new command can be used to manage Sitewide Notices via the command line.

wp bp notice

wp bp activity delete-comment

This new command can be used to remove activity comments via the command line.

delete-comment and remove-comment are aliases added for the, now removed, wp bp activity delete_comment command.

wp bp activity delete-comment

Removed Commands

wp bp group invite remove

This command was removed and replaced by the new wp bp group invite uninvite command to avoid a conflict, and confusion, with the delete/remove command (where the invite is actually deleted from the database). This is the new way to uninvite a user via the BP CLI.

wp bp activity delete_comment

This command was removed and replaced by the new wp bp activity delete-comment.

wp bp activity favorite user_items

The user_items and items command aliases were removed from the wp bp activity favorite list command.

Noteworthy changes to commands

We polished the implementation of many commands. Here are some noteworthy changes:

  • wp bp tool signup this command can be used to activate or deactivate the BuddyPress signup feature in a multisite installation.
  • Support for the --silence flag introduced to create commands.
  • Support for the --silence flag introduced to the wp bp activity comment command.
  • Support for the --format and --silent flags for the generate commands.
  • Confirmation message updated for delete commands that accepts multiple values
  • PHPDoc improvements
    • All generate commands’ output were standardized
    • All create commands’ output were standardized
    • All delete commands’ output were standardized
    • All delete commands’ aliases were standardized
    • All list commands were standardized
    • Invalid --format option haml removed

Beginning testing against PHP 8.3

We are not testing for PHP 8.3. This paves the way for eventually supporting the 8.3 version.

And several other minor changes to improve the codebase, and make sure the commands would run smoothly.

#14-0-0, #wp-cli

Signups are becoming members only after validating their accounts

BuddyPress is using the $wpdb->signups table to manage signups since 2.0.0. This table which is only available into the WordPress Multisite DB schema is generated by BuddyPress on regular WordPress installs.

For 10 years we’ve been carrying on creating users to preserve backwards compatibility with 3rd party plugins relying on our “prehistorical” way of dealing with signups on regular WordPress configs, today we are finally deprecating this behavior to improve BuddyPress consistency and fix this 9 years old issue.

If you are still playing with the activation_key user meta and the {$wpdb->users}.user_status (which we used to set to 2 to mark a user as a signup), please update your code so that you now fully enjoy our BP Signups API.

In 14.0.0, we are throwing deprecation notices if you use the BP “prehistorical” way to deal with signups, but please note we will completely remove this code in 15.0.0.

#14-0-0, #developers