Using The Membership Level Meta API

Restrict Content Pro version 2.6 introduced a metadata API for membership levels. This allows developers to store metadata that is directly associated with particular membership levels.

This API works nearly identical to the standard WordPress metadata API.

global $rcp_levels_db;

// Add metadata
$rcp_levels_db->add_meta( $level_id = 0, $key = '', $value = '', $unique = true );

// Update metadata
$rcp_levels_db->update_meta( $level_id = 0, $key = '', $value = '', $previous_value = '' );

// Retrieve metadata
$rcp_levels_db->get_meta( $level_id = 0, $key = '', $single = true );

// Delete metadata
$rcp_levels_db->delete_meta( $level_id = 0, $key = '', $value = '' );

Version 3.1 also introduced new helper functions. These functions are just a different way of doing the exact same thing as above:

// Add metadata
rcp_add_membership_level_meta( $level_id, $meta_key, $meta_value, $unique = false );

// Update metadata
rcp_update_membership_level_meta( $level_id, $meta_key, $meta_value, $prev_value = '' );

// Retrieve metadata
rcp_get_membership_level_meta( $level_id, $key = '', $single = false );

// Delete metadata
rcp_delete_membership_level_meta( $level_id, $meta_key, $meta_value = '' );
Powered by Zendesk