Add specific URLs to be restricted following user categories. Supports also regular expressions, so you can target multiple pages at once.
Users not having correct permissions will be moved to main redirect target.
Parameters
(array) associative array having URL as key and restriction pattern as value
Usage
<?php
// restrict an URL or URLs matching a regular expression, allowing only users belonging to categories 2 and 4 - blocking 3
function foo($restrictet_urls) {
$restrictet_urls['http://www.lcweb.it/privatecontent/public-api'] = array(
'allowed' => '2,4'
'blocked' => 3
);
return $restrictet_urls;
}
add_filter('pc_custom_restriction', 'foo');
?>
pc_customize_message
Customize a specific plugin message, overriding previously declared customizations in settings.
<?php
// customize message for logged in users
function foo($mess, $subj) {
if($subj == 'pc_login_ok_mex') {
return 'Custom message!';
}
}
add_filter('pc_customize_message', 'foo', 10, 2);
?>
pc_data_to_human
Customize how fetched database data is returned through data_to_human() method.
Be careful: once you use it, default data management is overrided.
Parameters
(string) data as returned by database query (serialized data is unmanaged)
(string) field index
Usage
<?php
// costomize how name is returned, capitalizing it
function foo($data, $subj) {
if($subj == 'name') {
return strtoupper($data);
}
}
add_filter('pc_data_to_human', 'foo', 10, 2);
?>
pc_export_fields
Add fields to be included in exported data.
Passes through get_users method, then must be stored in meta data table.
Parameters
(array) fields key array to be fetched
Usage
<?php
// export also "test_field" - contained in meta-data table
function foo($to_get) {
$to_get[] = 'test_field';
return $to_get;
}
add_filter('pc_export_fields', 'foo');
?>
pc_extra_user_check
Gives a chance to perform a further check over the pc_user_check() API function.
NB: user is logged then its ID can be retrieved through $GLOBALS['pc_user_id'].
Parameters
(int) this filter must return a proper value: 1 == ok or 2 == blocked
(array) User categories
(array) $allowed pc_user_check() parameter
(array) $blocked pc_user_check() parameter
Usage
<?php
// block user assigned to category #3
function foo($response, $user_cats, $allowed, $blocked) {
if(in_array(3, $user_cats)) {
$response = 2;
}
return $response;
}
add_filter('pc_extra_user_check', 'foo', 10, 4);
?>
pc_form_fields_filter
Extend PrivateContent fields adding new ones.
New fields automatically setup also validations.
Parameters
Only one parameter: associative array of associative array(field-key => values array) containing existing fields.
Each array element defines a specific field aspect and validation parameters. Here's a guideline for indexes and possible values
key
description
(string) (mandatory) label
field label, used alo in forms
(string) (mandatory) type
field type. Choose among:
text
text field (cases may be specified in subtype)
select
dropdown field
textarea
checkbox
multi-option checkbox
single_checkbox
single-option checkbox
(string) subtype
text fields subtype.
Leave empty to use a normal text input or choose among:
email
inserted data have to match e-mail format
int
inserted data must be an integer number
float
inserted data must be a floating number (international format)
eu_date
inserted data must be an european date DD/MM/YYYY
us_date
inserted data must be an american date MM/DD/YYYY
us_tel
inserted data must be an american telephone number
zipcode
inserted data must be an american ZIP code
url
inserted data must be a valid URL
(int) maxlen
textual fields characters limitation
(string) regex
textual fields advanced validation. Will be used with preg_match() function
(int) range_from
numeric fields limit, defines minimum accepted value.
Could be a floating number according to chosen subytpe
(int) range_to
numeric fields limit, defines maximum accepted value.
Could be a floating number according to chosen subytpe
(string) options
select field options. They must be comma split
(string) placeh
textual fields placeholder
(bool) multiple
select field switch: true to allow multi-option selection
(string) check_txt
single-option checkbox parameter, defining text shown on check's side
(bool) disclaimer
single-option checkbox switch: true if field must be shown in disclaimers box
Usage
<?php
// add a new integer text field with specific limitations and a dropdown field
function foo($fields) {
$fields['new_field1'] = array(
'label' => 'Field 1 Label',
'type' => 'text',
'subtype' => 'int',
'range_from'=> 10,
'range_to' => 50,
'placeh' => 'insert a number between 10 and 50',
'note' => 'internal note',
);
$fields['new_field2'] = array(
'label' => 'Field 2 Label'
'type' => 'select',
'opt' => 'opt 1, opt 2, opt 3'
'note' => 'internal note'
'multiple' => false
);
return $fields;
}
add_filter('pc_form_fields_filter', 'foo');
?>
pc_form_valid_errors
Adds the ability to perform custom validations in forms managed by form framework class (registration, insertion, update).
Parameters
(array) array of errors already found, HTML ready to be printed
(array) associative array of fetched value (field_name => field_value)
Usage
<?php
// return an error if e-mail field doesn't contain @lcweb.it
function foo($errors, $fdata) {
if(isset($fdata['email']) && strpos($fdata['email'], '@lcweb.it') === false) {
$errors[] = 'E-mail must be of @lcweb.it domain!';
}
return $errors;
}
add_filter('pc_form_valid_errors', 'foo', 10, 2);
?>
pc_insert_user_data_check
Performs custom data validation before user is inserted into database
Parameters
(string) errors already found, HTML readyto be printed
(array) associative array of fetched value (field_name => field_value)
Usage
<?php
// return an error if e-mail field doesn't contain @lcweb.it
function foo($errors, $fdata) {
if(isset($fdata['email']) && strpos($fdata['email'], '@lcweb.it') === false) {
$errors .= ' E-mail must be of @lcweb.it domain!';
}
return $errors;
}
add_filter('pc_insert_user_data_check', 'foo', 10, 2);
?>
pc_insert_user_required_fields
Set additional required fields for user insertion
Parameters
(array) array containing field names. Values must be registered in form framework
Usage
<?php
// set name field as mandatory
function foo($fields) {
$fields['name'];
return $fields;
}
add_filter('pc_insert_user_required_fields', 'foo');
?>
pc_login_custom_check
Allows custom checks before allowing user to log in
Parameters
(bool/text) by default is false and allow login. Return text to abort login
(int) user ID - useful to perform database checks
pc_meta_val
Additional data management for fetched meta values
Parameters
(mixed) fetched meta value (array and objects already unserialized)
(string) meta key
Usage
<?php
// use strtoupper on fetched meta "test"
function foo($val, $meta_key) {
if($meta_key == 'test') {
$val = strtoupper($val);
}
return $val;
}
add_filter('pc_insert_user_required_fields', 'foo', 10, 2);
?>
pc_pvt_page_contents
Manage users private page contents. Useful to prepend or append elements
Parameters
(string) private page contents
Usage
<?php
// print 'lorem ipsum' paragraph before contents
function foo($contents) {
return '
Manage registration forms structure. Set included and required fields.
Fields must be registered in form framework.
Parameters
(array) associative array having this structure array('include' => included fields array, 'require' => included fields array)
(int) registration form ID
Usage
<?php
// add 'test' field into registation form and set it as required
function foo($structure) {
$structure['include'][] = 'test';
$structure['require'][] = 'test';
return $structure;
}
add_filter('pc_registration_form', 'foo', 10, 2);
?>
pc_settings_validations
Add validation indexes to settings page. Must comply with Simple Form Validator format.
For every succcessfully validated index will be created a WordPress option
<?php
// add 'pc_test' field into validated fields
function foo($indexes) {
$indexes[] = array('index'=>'pc_test', 'label'=>'Test', 'type'=>'int');
return $indexes;
}
add_filter('pc_settings_validations', 'foo');
// if successfully validated - you can get that through get_option('pc_test');
?>
pc_update_user_data_check
Performs custom data validation before user is updated
Parameters
(string) errors already found, HTML readyto be printed
(array) associative array of fetched value (field_name => field_value)
Usage
<?php
// return an error if e-mail field doesn't contain @lcweb.it
function foo($errors, $fdata) {
if(isset($fdata['email']) && strpos($fdata['email'], '@lcweb.it') === false) {
$errors .= ' E-mail must be of @lcweb.it domain!';
}
return $errors;
}
add_filter('pc_update_user_data_check', 'foo', 10, 2);
?>
pc_update_user_required_fields
Customize required fields for user update
Parameters
(array) required fields array. Fields must be registered in form framework
pc_user_dashboard_validation
Add fields to validate and save in "add user" page.
Additional fields must be inserted into form framework through pc_form_fields_filter filter.
Parameters
First parameter (array) passes form structure (array of fields key).