PrivateContent Plugin
API Documentation
Constants & Globals
Constants
#PrivateContent defines PHP constants to speed up coding.
| Constant | Description |
|---|---|
PC_DIR | PrivateContent base directory (without trailing slash) |
PC_URL | PrivateContent base URL (without trailing slash) |
PC_VERS | PrivateContent version (eg. 9.15.1). Useful for version_compare() checks |
PC_USERS_TABLE | users database table name, prefix included. Defined on plugins_loaded (priority 1) |
PC_META_TABLE | user meta database table name, prefix included. Defined on plugins_loaded (priority 1) |
PVTCONT_WP_USER_PASS | true if the logged WordPress user can bypass restrictions (see the "testing mode" settings). Defined on pvtcont_init (priority 1) |
PVTCONT_CURR_USER_MANAGEABLE_CATS | any or array of user category IDs the logged WordPress user can manage. Defined on pvtcont_init (priority 1) |
Use defined() before using constants in code that might run earlier than the moment they are defined.
Global objects
#Main classes are instantiated once and reachable through PHP globals:
| Global | Description |
|---|---|
$pc_users | pc_users class instance - users management |
$pc_meta | pc_meta class instance - user meta management |
$pc_wp_user | pc_wp_user class instance - WP User Sync |
$pc_restr_wizard | pc_restr_wizard class instance - restrictions. Available from plugins_loaded (priority 100) |
Example
global $pc_users;
$email = $pc_users->get_user_field(5, 'email'); Global variables
#| Variable | Description |
|---|---|
$GLOBALS['pc_user_id'] | ID of the logged user. Set on pvtcont_init (priority 1) and unset on logout. It is not re-checked against the database: use pc_user_logged() for a real-time check |
$GLOBALS['pvtcont_user_check_already_passed'] | available only inside the pc_extra_user_check filter: true if the user already passed the standard categories check |
$GLOBALS['pvtcont_wp_preview_check_already_passed'] | available only inside the pc_extra_wp_preview_check filter: true if the previewing admin already passed the standard check |
$GLOBALS['pvtcont_check_user_id_is_username'] | if set, user meta methods treat the user parameter as a username even if it is numeric (useful for numeric usernames) |
$GLOBALS['is_pc_bundle'] | set when PrivateContent runs as part of the bundle pack |