wpmem_create_membership

Description

Creates a membership.

Parameters

$args
(array) (required) Parameters for creating the membership CPT.

  • (string) title User readable name of membership.
  • (string) name Sanitized title of the membership to be used as the meta key.
  • (string) status Published status: publish|draft (default: publish)
  • (int) author User ID of membership author, Optional, defaults to site admin.
  • (array) meta_input Meta fields for membership CPT (optional)
    • (string) name The sanitized title of the membership.
    • (string) default
    • (string) role Roles if a role is required.
    • (string) expires Expiration period if used (num|per).
    • (int) no_gap If renewal is “no gap” renewal.
    • (string) fixed_period (start|end|grace_num|grace_per)
    • (int) set_default_{key}
    • (string) message Custom message for restriction.
    • (int) child_access If membership hierarchy is used.

Usage

[snippet slug=wpmem_create_membership lang=php]

Notes

  • The only required value in the $args array is the “title” (user readable name of the membership). All other values can be created with defaults.

Changelog

  • Introduced in version 3.4.6

Source

wpmem_create_membership() is located in /includes/api/api-products.php