{"id":249,"date":"2016-01-15T23:33:52","date_gmt":"2016-01-15T23:33:52","guid":{"rendered":"http:\/\/buddydev.com\/mediapress\/?p=249"},"modified":"2016-01-15T23:46:43","modified_gmt":"2016-01-15T23:46:43","slug":"mpp_register_status","status":"publish","type":"post","link":"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/","title":{"rendered":"mpp_register_status"},"content":{"rendered":"<h3>mpp_register_status( $args )<\/h3>\n<p>Register a new media\/gallery status(privacy level)<\/p>\n<h3>Description<\/h3>\n<p>This\u00a0function is used to register new privacy level.<\/p>\n<h3>Parameters<\/h3>\n<p><strong>$args<\/strong><\/p>\n<ul>\n<li>key (string) (Required)\u00a0Unique identifier for this status. Example &#8220;private&#8221;, &#8220;loggedin&#8221;,&#8221;public&#8221; etc.<\/li>\n<li>label (string) (Required)\u00a0A name for this status. Example:- &#8220;Public&#8221;, &#8220;Private&#8221;, &#8220;Logged in Users Only&#8221;<\/li>\n<li>labels (array) (Required\u00a0)\u00a0An associative array with two keys, &#8220;singular_name&#8221;, &#8220;plural_name&#8221; the values represent labels.<\/li>\n<li>description (string) (Optional)\u00a0A textual description of this status<\/li>\n<li>callback (Callable) (Required )\u00a0A callback which will be called and passed component, component_id and user_id to determine of the current user can access a gallery\/media<\/li>\n<li>activity_privacy (string) (Optional):- Just a compat privacy level if you are planning to make your privacy compatible with BuddyPress Activity privacy plugin<\/li>\n<\/ul>\n<h3>Returns<\/h3>\n<p>It does not return anything.<\/p>\n<h3>\u00a0Examples<\/h3>\n<p>The code shows\u00a0how we register the Friends only privacy<\/p>\n<pre class=\"lang:default decode:true\">function mpp_register_custom_status() {\r\n\t\t\r\n\t\tmpp_register_status( array(\r\n\t\t\t\t'key'\t\t\t\t=&gt; 'friendsonly',\r\n\t\t\t\t'label'\t\t\t\t=&gt; __( 'Friends Only', 'mediapress' ),\r\n\t\t\t\t'labels'\t\t\t=&gt; array( \r\n\t\t\t\t\t\t\t\t\t\t'singular_name' =&gt; __( 'Friends Only', 'mediapress' ),\r\n\t\t\t\t\t\t\t\t\t\t'plural_name'\t=&gt; __( 'Friends Only', 'mediapress' )\r\n\t\t\t\t),\r\n\t\t\t\t'description'\t\t=&gt; __( 'Friends Only Privacy Type', 'mediapress' ),\r\n\t\t\t\t'callback'\t\t\t=&gt; 'mpp_check_friends_access',\/\/callable, see the below definition for parameters\r\n\t\t\t\t'activity_privacy'\t=&gt; 'friends',\/\/optional, just for activity privacy compat\r\n\t\t));\r\n\t\t\r\n}\r\n\r\nadd_action( 'mpp_setup', 'mpp_register_custom_status', 11 );\r\n<\/pre>\n<p>Here is the callback defined for the above status<\/p>\n<pre class=\"lang:default decode:true \">\/**\r\n * Check if the User Can access friends only gallery\/media for the given component and component_id\r\n * @param string $component_type the identifier for component to which the current gallery\/media is being checked  e.g \"sitewide\", \"members\", \"groups\" etc\r\n * @param int $component_id id of the component with which the media is associated( can be group id or user id or gallery id based on component)\r\n * @param int $user_id\r\n * @return boolean true if access is allowed else false\r\n *\/\r\nfunction mpp_check_friends_access ( $component_type, $component_id, $user_id = null ) {\r\n\r\n\t$allow = false;\r\n\r\n\tif ( is_super_admin() || $component_id == $user_id || bp_is_active( 'friends' ) &amp;&amp; ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $component_id ) ) ) {\r\n\t\t$allow = true;\r\n\t}\r\n\t\r\n\treturn apply_filters( 'mpp_check_friends_access', $allow, $component_type, $component_id, $user_id );\r\n}\r\n<\/pre>\n<p>As you might have noticed, the callback gets the <strong>component<\/strong> as first parameter. It can be one of the registered component( currently, the\u00a03 components registered in the core are \u00a0&#8220;sitewide&#8221;, &#8220;members&#8221;, &#8220;groups&#8221;)<\/p>\n<p><strong>$component_id:-<\/strong> 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.<\/p>\n<p><strong>$user_id<\/strong>:- A numeric id of the user for whom we are checking access to the given component&#8217;s(User&#8217;s in this case) gallery.<\/p>\n<h3>Note:-<\/h3>\n<p>It must be used on or after &#8220;mpp_setup_core&#8221; action.<\/p>\n<h3>See also:-<\/h3>\n<p><a href=\"https:\/\/buddydev.com\/mediapress\/topics\/api-reference\/core\/status\/mpp_deregister_status\/\">mpp_deregister_status<\/a><\/p>\n<h3>\u00a0Changelog<\/h3>\n<ul>\n<li>Since 1.0.0<\/li>\n<\/ul>\n<h3>Source<\/h3>\n<p>medisapress\/core\/api\/mpp-api.php<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>mpp_register_status( $args ) Register a new media\/gallery status(privacy level) Description This\u00a0function is used to register new privacy level. Parameters $args key (string) (Required)\u00a0Unique identifier for this status. Example &#8220;private&#8221;, &#8220;loggedin&#8221;,&#8221;public&#8221; etc. label (string) (Required)\u00a0A name for this status. Example:- &#8220;Public&#8221;, &#8220;Private&#8221;, &#8220;Logged in Users Only&#8221; labels (array) (Required\u00a0)\u00a0An associative array with two keys, &#8220;singular_name&#8221;, &#8220;plural_name&#8221; &#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4908],"tags":[],"class_list":["clearfix","post-249","post","type-post","status-publish","format-standard","hentry","category-status"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>mpp_register_status &#8226; MediaPress | BuddyDev<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"mpp_register_status &#8226; MediaPress | BuddyDev\" \/>\n<meta property=\"og:description\" content=\"mpp_register_status( $args ) Register a new media\/gallery status(privacy level) Description This\u00a0function is used to register new privacy level. Parameters $args key (string) (Required)\u00a0Unique identifier for this status. Example &#8220;private&#8221;, &#8220;loggedin&#8221;,&#8221;public&#8221; etc. label (string) (Required)\u00a0A name for this status. Example:- &#8220;Public&#8221;, &#8220;Private&#8221;, &#8220;Logged in Users Only&#8221; labels (array) (Required\u00a0)\u00a0An associative array with two keys, &#8220;singular_name&#8221;, &#8220;plural_name&#8221; ...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/\" \/>\n<meta property=\"og:site_name\" content=\"MediaPress | BuddyDev\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/bpdev\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-15T23:33:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-01-15T23:46:43+00:00\" \/>\n<meta name=\"author\" content=\"Brajesh Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@sbrajesh\" \/>\n<meta name=\"twitter:site\" content=\"@buddydev\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brajesh Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/\",\"url\":\"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/\",\"name\":\"mpp_register_status &#8226; MediaPress | BuddyDev\",\"isPartOf\":{\"@id\":\"https:\/\/buddydev.com\/mediapress\/#website\"},\"datePublished\":\"2016-01-15T23:33:52+00:00\",\"dateModified\":\"2016-01-15T23:46:43+00:00\",\"author\":{\"@id\":\"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb\"},\"breadcrumb\":{\"@id\":\"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/buddydev.com\/mediapress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"mpp_register_status\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/buddydev.com\/mediapress\/#website\",\"url\":\"https:\/\/buddydev.com\/mediapress\/\",\"name\":\"MediaPress | BuddyDev\",\"description\":\"The Best Media Gallery Plugin For BuddyPress\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/buddydev.com\/mediapress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb\",\"name\":\"Brajesh Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/image\/\",\"url\":\"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon\",\"contentUrl\":\"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon\",\"caption\":\"Brajesh Singh\"},\"sameAs\":[\"http:\/\/buddydev.com\/members\/sbrajesh\/\",\"https:\/\/x.com\/sbrajesh\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"mpp_register_status &#8226; MediaPress | BuddyDev","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/","og_locale":"en_US","og_type":"article","og_title":"mpp_register_status &#8226; MediaPress | BuddyDev","og_description":"mpp_register_status( $args ) Register a new media\/gallery status(privacy level) Description This\u00a0function is used to register new privacy level. Parameters $args key (string) (Required)\u00a0Unique identifier for this status. Example &#8220;private&#8221;, &#8220;loggedin&#8221;,&#8221;public&#8221; etc. label (string) (Required)\u00a0A name for this status. Example:- &#8220;Public&#8221;, &#8220;Private&#8221;, &#8220;Logged in Users Only&#8221; labels (array) (Required\u00a0)\u00a0An associative array with two keys, &#8220;singular_name&#8221;, &#8220;plural_name&#8221; ...","og_url":"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/","og_site_name":"MediaPress | BuddyDev","article_publisher":"https:\/\/www.facebook.com\/bpdev","article_published_time":"2016-01-15T23:33:52+00:00","article_modified_time":"2016-01-15T23:46:43+00:00","author":"Brajesh Singh","twitter_card":"summary_large_image","twitter_creator":"@sbrajesh","twitter_site":"@buddydev","twitter_misc":{"Written by":"Brajesh Singh","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/","url":"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/","name":"mpp_register_status &#8226; MediaPress | BuddyDev","isPartOf":{"@id":"https:\/\/buddydev.com\/mediapress\/#website"},"datePublished":"2016-01-15T23:33:52+00:00","dateModified":"2016-01-15T23:46:43+00:00","author":{"@id":"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb"},"breadcrumb":{"@id":"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/buddydev.com\/mediapress\/status\/mpp_register_status\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/buddydev.com\/mediapress\/"},{"@type":"ListItem","position":2,"name":"mpp_register_status"}]},{"@type":"WebSite","@id":"https:\/\/buddydev.com\/mediapress\/#website","url":"https:\/\/buddydev.com\/mediapress\/","name":"MediaPress | BuddyDev","description":"The Best Media Gallery Plugin For BuddyPress","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/buddydev.com\/mediapress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb","name":"Brajesh Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/image\/","url":"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon","contentUrl":"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon","caption":"Brajesh Singh"},"sameAs":["http:\/\/buddydev.com\/members\/sbrajesh\/","https:\/\/x.com\/sbrajesh"]}]}},"_links":{"self":[{"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/posts\/249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/comments?post=249"}],"version-history":[{"count":5,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/posts\/249\/revisions"}],"predecessor-version":[{"id":259,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/posts\/249\/revisions\/259"}],"wp:attachment":[{"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/media?parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/categories?post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/tags?post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}