BuddyDev

Search

mpp_register_status( $args )

Register a new media/gallery status(privacy level)

Description

This function is used to register new privacy level.

Parameters

$args

  • key (string) (Required) Unique identifier for this status. Example “private”, “loggedin”,”public” etc.
  • label (string) (Required) A name for this status. Example:- “Public”, “Private”, “Logged in Users Only”
  • labels (array) (Required ) An associative array with two keys, “singular_name”, “plural_name” the values represent labels.
  • description (string) (Optional) A textual description of this status
  • callback (Callable) (Required ) A callback which will be called and passed component, component_id and user_id to determine of the current user can access a gallery/media
  • activity_privacy (string) (Optional):- Just a compat privacy level if you are planning to make your privacy compatible with BuddyPress Activity privacy plugin

Returns

It does not return anything.

 Examples

The code shows how we register the Friends only privacy

Here is the callback defined for the above status

As you might have noticed, the callback gets the component as first parameter. It can be one of the registered component( currently, the 3 components registered in the core are  “sitewide”, “members”, “groups”)

$component_id:- It identifies the current owner object. For example, in case of User gallery, It is set to user_id , in case of group gallery, It is the id of the group and in case of the sitewide gallery, It is the gallery id itself.

$user_id:- A numeric id of the user for whom we are checking access to the given component’s(User’s in this case) gallery.

Note:-

It must be used on or after “mpp_setup_core” action.

See also:-

mpp_deregister_status

 Changelog

  • Since 1.0.0

Source

medisapress/core/api/mpp-api.php

 

Subscribe