1. Home
  2. Knowledge Base
  3. API
  4. Function Reference
  5. Function Reference: wlmapi_protect_category

Function Reference: wlmapi_protect_category

Protects a category.

Parameters

  • args (array) – An array of accepted arguments specified below:
Parameter Description Required Default
ContentIds (array) An array of category IDs to protect Required

Return

Returns a multi-dimensional array containing operation status and an array containing all protected categories.

Example Code

<?php
     $args = array(
          'ContentIds' => array(11,12)
     );
     $categories = wlmapi_protect_category($args);
     print_r($categories);
?>

Example Output

Array
(
    [success] => 1
    [categories] => Array
        (
            [category] => Array
                (
                    [0] => Array
                        (
                            [ID] => 9
                            [name] => Child Category I
                        )

                    [1] => Array
                        (
                            [ID] => 10
                            [name] => Child Category II
                        )

                    [2] => Array
                        (
                            [ID] => 11
                            [name] => Child Category III
                        )

                    [3] => Array
                        (
                            [ID] => 12
                            [name] => Grandchild Category I
                        )

                    [4] => Array
                        (
                            [ID] => 6
                            [name] => Parent Category I
                        )

                    [5] => Array
                        (
                            [ID] => 7
                            [name] => Parent Category II
                        )

                    [6] => Array
                        (
                            [ID] => 8
                            [name] => Parent Category III
                        )

                    [7] => Array
                        (
                            [ID] => 1
                            [name] => Uncategorized
                        )

                )

        )

    [supported_verbs] => Array
        (
            [0] => GET
            [1] => POST
        )

)

Notes

This functions returns WLMAPIMethods::protect_category($args) in core/api-helper/class-api-methods.php

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support