Skip to content

Instantly share code, notes, and snippets.

@alfredo-wpmudev
Created May 15, 2024 18:38
Show Gist options
  • Save alfredo-wpmudev/0e0a395ca83309d4e03e46b5874c2b67 to your computer and use it in GitHub Desktop.
Save alfredo-wpmudev/0e0a395ca83309d4e03e46b5874c2b67 to your computer and use it in GitHub Desktop.
Show entry IP in the Forminator Submission without the need to add any extra fiekd
<?php
/**
* Plugin Name: [Forminator Pro] - Show IPs on the submission list
* Plugin URI: https://premium.wpmudev.org/
* Description: Show IPs on the submission list
* Author: Alfredo Galano Loyola | @WPMUDEV
* Author URI: https://premium.wpmudev.org/
* License: GPLv2 or later
*/
if (!defined('ABSPATH')) {
exit;
}
// No need to do anything if the request is via WP-CLI.
if (defined('WP_CLI') && WP_CLI) {
return;
}
if (!class_exists('WPMUDEV_Forminator_Show_IPs')) {
class WPMUDEV_Forminator_Show_IPs
{
private static $_instance = null;
public static function get_instance()
{
if (is_null(self::$_instance)) {
self::$_instance = new WPMUDEV_Forminator_Show_IPs();
}
return self::$_instance;
}
private function __construct()
{
/*Customize your data to load here */
/*Stop customizing */
if (!defined('FORMINATOR_VERSION') || FORMINATOR_VERSION < '1.12') {
return;
}
$this->init();
}
public function init()
{
// change number order for admin:
add_filter('forminator_custom_form_entries_iterator', array($this, 'custom_order_number_for_admin'), 10, 2);
}
public function custom_order_number_for_admin($iterator, $entry)
{
$entry_ip = $entry->get_meta('_forminator_user_ip');
if ($entry_ip) {
array_unshift($iterator['detail']['items'], array(
'type' => 'text',
'label' => 'IP',
'value' => $entry_ip,
'sub_entries' => array(),
));
}
return $iterator;
}
}
add_action('plugins_loaded', function () {
return WPMUDEV_Forminator_Show_IPs::get_instance();
});
}
@alfredo-wpmudev
Copy link
Author

2024-05-15_125145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment