Gives a membership level access to the specified post according to the specified arguments.
Parameters
- level_id (int) – The ID of the level to add posts to
- args (array) – An array of accepted arguments specified below:
Parameter | Description | Required | Default |
---|---|---|---|
ContentIds (array) | An array of post IDs to add to the membership level | Required |
Return
Returns a multi-dimensional array containing operation status and an array containing all the posts that membership level has access to.
Example Code
<?php $args = array( 'ContentIds' => array(1,96) ); $posts = wlmapi_add_post_to_level(1340726008, $args); print_r($posts); ?>
Example Output
Array ( [success] => 1 [posts] => Array ( [post] => Array ( [0] => Array ( [ID] => 1 [name] => Hello world! [_more_] => /levels/1340726008/posts/1 ) [1] => Array ( [ID] => 96 [name] => Auto Reg [_more_] => /levels/1340726008/posts/96 ) ) ) [supported_verbs] => Array ( [0] => GET [1] => POST ) )
Notes
This functions returns WLMAPIMethods::add_post_to_level($level_id, $args) in core/api-helper/class-api-methods.php