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

Function Reference: wlmapi_create_level

Creates a new membership level according to the specified arguments.


  • args (array) – An array of accepted arguments specified below:
Parameter Description Required Default
name (string) The name of the membership level. Required.
registration_url (string) The Registration URL slug. Optional. auto-generated
after_login_redirect (mixed) global, homepage, or $page_id. Optional. global
after_registration_redirect (mixed) global, homepage, or $page_id. Optional. global
access_all_pages (boolean) If level can access all pages. Optional. false
access_all_categories (boolean) If level can access all categories. Optional. false
access_all_posts (boolean) If level can access all posts. Optional. false
access_all_comments (boolean) If level can access all comments. Optional. false
no_expiry (boolean) If level has no expiration. Optional. true
expiry (int) The expiration unit amount (ignored if no_expiry is set to true). Optional.
expiry_period (string) The unit type relating to expiry (Days, Weeks, Months, Years). Optional. Days
sequential_upgrade_to (int) Level ID to upgrade level to. Leave blank to disable sequential upgrade for level. Optional.
sequential_upgrade_after (int) Number of days for sequential upgrade. Optional.
sequential_upgrade_method (string) ADD or MOVE. Optional.
require_captcha (boolean) Whether to require CAPTCHA on registration form. Optional. false
require_email_confirmation (boolean) Whether to require email confirmation. Optional. false
require_admin_approval (boolean) Whether to require admin approval. Optional. false
grant_continued_access (boolean) Whether to grant continued access. Optional. false
disable_existing_users_link (boolean) Whether to disable the “Existing Users” link. Optional. false
registration_date_reset (boolean) Whether to reset the members registration data on re-registration. Optional. false
uncancel_on_registration (boolean) Whether to un-cancel member on re-registration. Optional. false
wordpress_role (string) The WordPress role. Optional. subscriber
level_order (integer) Number representing the level's order Optional.
remove_from (array) An array of level IDs to remove a user from when a user is added to this level. Optional.


Returns a multi-dimensional array containing data for the newly created membership level.

Example Code

     $args = array('name' => 'Test Level 4');
     $level = wlmapi_create_level($args);

Example Output

    [success] => 1
    [level] => Array
            [id] => 1344363854
            [name] => Test Level 4
            [registration_url] => BFKdgl
            [after_login_redirect] => global
            [after_registration_redirect] => global
            [access_all_pages] => 0
            [access_all_categories] => 0
            [access_all_posts] => 0
            [access_all_comments] => 0
            [no_expiry] => 1
            [expiry] => 
            [expiry_period] => Days
            [sequential_upgrade_to] => 
            [sequential_upgrade_after] => 
            [sequential_upgrade_method] => 
            [member_count] => 
            [require_captcha] => 0
            [require_email_confirmation] => 0
            [require_admin_approval] => 0
            [grant_continued_access] => 0
            [disable_existing_users_link] => 0
            [registration_date_reset] => 0
            [uncancel_on_registration] => 0
            [wordpress_role] => subscriber
            [level_order] => 
            [remove_from_levels] => 
            [_more_] => Array
                    [0] => /levels/1344363854/members
                    [1] => /levels/1344363854/posts
                    [2] => /levels/1344363854/pages
                    [3] => /levels/1344363854/comments
                    [4] => /levels/1344363854/categories


    [supported_verbs] => Array
            [0] => GET
            [1] => PUT
            [2] => DELETE



This functions returns WLMAPIMethods::create_level($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