Plugin / Post Author IP
Scott ReillyDescription
Description
This plugin records the IP address of the original post author when a post first gets created.
The admin listing of posts is amended with a new “Author IP” column that shows the IP address of the author who first saved the post.
The plugin is unable to provide IP address information for posts that were created prior to the use of this plugin.
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
Hooks
The plugin is further customizable via four filters. Typically, code making use of filters should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain).
c2c_show_post_author_ip_column (filter)
The ‘c2c_show_post_author_ip_column’ filter allows you to determine if the post author IP column should appear in the admin post listing table. Your hooking function can be sent 1 argument:
Argument :
- $show_column (bool) Should the column be shown? Default true.
Example:
/**
* Don't show the post author IP column except to admins.
*
* @param bool $show_column Should the column be shown? Default true.
* @return bool
*/
function post_author_ip_column_admin_only( $show ) {
if ( ! current_user_can( 'manage_options' ) ) {
$show = false;
}
return $show;
}
add_filter( 'c2c_show_post_author_ip_column', 'post_author_ip_column_admin_only' );
c2c_get_post_author_ip (filter)
The ‘c2c_get_post_author_ip’ filter allows you to customize the value stored as the post author IP address. Your hooking function can be sent 2 arguments:
Arguments :
- $ip (string) The post author IP address.
- $post_id (int) The post ID.
Example:
/**
* Store all IP addresses from local subnet IP addresses as the same IP address.
*
* @param string $ip The post author IP address.
* @param int $post_id The post ID.
* @return string
*/
function customize_post_author_ip( $ip, $post_id ) {
if ( 0 === strpos( $ip, '192.168.' ) ) {
$ip = '192.168.1.1';
}
return $ip;
}
add_filter( 'c2c_get_post_author_ip', 'customize_post_author_ip', 10, 2 );
c2c_get_current_user_ip (filter)
The ‘c2c_get_current_user_ip’ filter allows you to customize the current user’s IP address, as used by the plugin. Your hooking function can be sent 1 argument:
Argument :
- $ip (string) The post author IP address.
Example:
/**
* Overrides localhost IP address.
*
* @param string $ip The post author IP address.
* @param int $post_id The post ID.
* @return string
*/
function customize_post_author_ip( $ip, $post_id ) {
if ( 0 === strpos( $ip, '192.168.' ) ) {
$ip = '192.168.1.1';
}
return $ip;
}
add_filter( 'c2c_get_post_author_ip', 'customize_post_author_ip', 10, 2 );
c2c_post_author_ip_allowed (filter)
The ‘c2c_post_author_ip_allowed’ filter allows you to determine on a per-post basis if the post author IP should be stored. Your hooking function can be sent 3 arguments:
Arguments :
- $allowed (bool) Can post author IP be saved for post? Default true.
- $post_id (int) The post ID.
- $ip (string) The post author IP address.
Example:
/**
* Don't bother storing localhost IP addresses.
*
* @param bool $allowed Can post author IP be saved for post? Default true.
* @param int $post_id The post ID.
* @param string $ip The post author IP address.
* @return string
*/
function disable_localhost_post_author_ips( $allowed, $post_id, $ip ) {
if ( $allowed && 0 === strpos( $ip, '192.168.' ) ) {
$allowed = false;
}
return $allowed;
}
add_filter( 'c2c_post_author_ip_allowed', 'disable_localhost_post_author_ips', 10, 3 );
Ratings
Rating breakdown
Details Information
Version
First Released
Total Downloads
Wordpress Version
Tested up to:
Require PHP Version:
Tags
Contributors
Languages
DIRECTORY DISCLAIMER
The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.
The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.
Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.
While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.
wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.