Hooks - Actions

pc_add_user_body

Add code into 'add user' admin page.
Remember fields must be inserted in form framework and inserted into validation engine through pc_add_user_form_validation filter.

Parameters
  1. (bool/array) associative array containing user data (field_key => data)
    If no user exists and no form has been submitted yet, is false
  2. (bool/int) User ID. If isn't been editing a user, is false
Usage
<?php
// add a new field in 'add user' page (structure is the one used in User Data add-on)
function foo($data) {
	
	// check if value has already been passed
	if(!empty($data) && isset($data['my_field'])) {
		$val = $data['my_field'];
	}
	else {
		$val = '';
	}
	
	echo '
	

My custom fields

My field label
'; } add_filter('pc_add_user_body', 'foo', 100, 2); ?>
pc_custom_style_css

Add CSS code into custom CSS file

Usage
<?php
// force forms to have a thick border
function foo($data) {
	?>
	.pc_registration_form, .pc_login_form, .pc_custom_form {
		border: 7px solid #aaa !important;	
	}
	<?php
}
add_filter('pc_custom_style_css', 'foo');
?>
pc_deleted_user

Perform actions after user deletion.
Its data and meta have alredy been deleted.

Parameters
  1. (int) user ID deleted
pc_import_form

Add fields into import form. Must comply with existing table code.

Usage
<?php
// add a dropdown 
function foo() {
	?>
	<tr>
	   <td class='pc_label_td'>Field label </td>
	   <td class='pc_field_td'>
		 
	   </td>
	   <td>Field description </td>
	</tr>
	<?php
}
add_action('pc_import_form', 'foo');
?>
pc_imported_users

Perform actions with imported users

Parameters
  1. (array) associative array (user_id => imported_data)
Usage
<?php
// send mail to imported users 
function foo($users) {
	foreach($users as $user_id => $data) {
		if(!empty($data['email'])) {
			
			wp_mail( ... ) // simplified code
		}
	}
}
add_action('pc_imported_users', 'foo');
?>
pc_pre_user_delete

Perform actions before user is deleted.
Data and metas are still reachable.

Parameters
  1. (int) user ID to be deleted
Usage
<?php
// send goodbye mail before deleting
function foo($user_id) {	
	// get mail
	global $pc_users;
	$email = $pc_users->get_user_field($user_id, 'email');
	
	if(!empty($email)) {
		wp_mail( ... ) // simplified code	
	}
}
add_action('pc_pre_user_delete', 'foo');
?>
pc_pvt_page_comments_template

Give the opportunity to override comments template on users private page.
Must return a path to the new commenta template.

pc_pvt_page_display

Users private page is being displayed (riggered in the_content hook)

pc_registered_user

Perform an action when user successfully registers with a registration form.

Parameters
  1. (int) newly registered user ID
  2. (int) newly registered user status
Usage
<?php
// add a meta value for newly registered user
function foo($user_id, $status) {	
	global $pc_meta;
	$pc_meta->add_meta($user_id, 'meta_key', 'meta_val');
}
add_action('pc_registered_user', 'foo', 10, 2);
?>
pc_restricted_comment_is_show

Restricted comments block is shown to user

pc_settings_messages

Insert new customizable messages in settings.
Remember to add related validation indexes

Parameters
  1. (array) associative array containing settings data (option_key => value)
Usage
<?php
// add a new cusomizable message to be used in custom codes
function foo($fdata) {	
	$val = (isset($fdata['custom_mess'])) ? $fdata['custom_mess'] : ''; 
	?>
	

My custom message

custom message label

custom message description

<?php } add_action('pc_settings_messages', 'foo'); ?>
pc_settings_tabs_body

Add contents related to inserted custom tabs into settings panel.

Parameters
  1. (array) associative array containing settings data (option_key => value)
Usage
<?php
// add contents related to a new settings tab named 'test'
function foo($fdata) {	
	$val = (isset($fdata['pc_my_option'])) ? $fdata['pc_my_option'] : ''; 
	?>
	

My custom message

option label

custom option description

<?php } add_action('pc_settings_tabs_body', 'foo'); ?>
pc_settings_tabs_list

Add tabs into settings panel. Code must comply with jQuery tabs (see usage)

Usage
<?php
// add 'test' tab in settings
function foo() {	
	?>
	
  • My custom tab
  • <?php } add_action('pc_settings_tabs_list', 'foo'); ?>
    pc_tinymce_tabs_list

    Add tabs into shortcode wizard lightbox. Code must comply with jQuery tabs (see usage)

    Usage
    <?php
    // add 'test' tab in settings
    function foo() {	
    	?>
    	
  • My custom tab
  • <?php } add_action('pc_tinymce_tabs_list', 'foo'); ?>
    pc_user_activated

    Perform an action when pending user is enabled through change_status method.

    Parameters
    1. (int) activated user ID
    Usage
    <?php
    // contact user via mail during activation
    function foo($user_id) {	
    	// get mail
    	global $pc_users;
    	$email = $pc_users->get_user_field($user_id, 'email');
    	
    	if(!empty($email)) {
    		wp_mail( ... ) // simplified code	
    	}
    }
    add_action('pc_user_activated', 'foo');
    ?>
    
    pc_user_added

    Perform an action when user is added into database.

    Parameters
    1. (int) inserted user ID
    Usage
    <?php
    // contact new user via mail
    function foo($user_id) {	
    	// get mail
    	global $pc_users;
    	$email = $pc_users->get_user_field($user_id, 'email');
    	
    	if(!empty($email)) {
    		wp_mail( ... ) // simplified code	
    	}
    }
    add_action('pc_user_added', 'foo');
    ?>
    
    pc_user_detached_from_wp

    Perform an action when user is detachecd from its Wordpress mirror.
    Action is performed right before WP user deletion.

    Parameters
    1. (int) user ID
    2. (int) mirror WP user ID
    pc_user_login

    Perform an action when user logs in

    Parameters
    1. (int) user ID
    pc_user_logout

    Perform an action when user logs out

    Parameters
    1. (int) user ID
    pc_user_synced_with_wp

    Perform an action when user is synced with a Wordpress mirror user.

    Parameters
    1. (int) user ID
    2. (int) mirror WP user ID
    pc_user_updated

    Perform an action when user is updated (any field or meta is updated)

    Parameters
    1. (int) user ID
    Usage
    <?php
    // contact user if admin update its data
    function foo($user_id) {	
    	// get mail
    	global $pc_users;
    	$email = $pc_users->get_user_field($user_id, 'email');
    	
    	if(!empty($email) && pc_user_logged(false) === false)) {
    		wp_mail( ... ) // simplified code	
    	}
    }
    add_action('pc_user_updated', 'foo');
    ?>
    
    lcwebPrivateContent – API documentation