[Forminator Pro] Details from submissions missing?

Hi,

At the documentation page for Forminator it says more details should be available for submissions: https://premium.wpmudev.org/docs/wpmu-dev-plugins/forminator/#submissions
Under Display Fields.
We would like to contact the users who didn't used the poll to remind them.
How can we view the data?

Gr, Age

  • Predrag Dubajic

    Hi jongag1,

    Submission filter shown on that page is for Forms, Polls will show total results out of all submissions.
    There are no filters for Polls since there are no additional fields in polls that could be filtered out.

    Could you elaborate a bit more how you have this set up and what is the result you're trying to achieve?
    Do you use From or Poll?
    Are you perhaps looking to see which users have voted in a Poll and based on that email the ones that didn't do it yet?
    If that's the case, are you blocking your poll from non-registered users?

    Best regards,
    Predrag

  • Adam Czajczyk

    Hi jongag1

    Thanks for additional explanation.

    Currently for polls Forminator doesn't save information about the user who voted in the database. There's an IP saved but not e.g. logged in user ID.

    So, first thing to do would be to make it actually save voting user account ID. Having that logged in the db would then make it relatively easy to compare that list against list of all registered users but I'm not sure whether saving that user ID would be possible in the first place :slight_smile:

    Let me consult our developers about that then. I have already asked them for advice and they'll see if that's possible and if so, if we could possibly provide some sort of custom code for this or not. Please keep an eye on this ticket and we'll update you here as soon as we get to know more.

    Best regards,
    Adam

  • Konstantinos Xenos

    Hey jongag1 ,

    I've created an accompanying mu-plugin to help out with what you're trying to achieve.

    This plugin will gather the user IDs on each Poll 'vote' into an option called "custom_poll_users" in the _options table of your installation. It will also add a new admin screen called "Poll Users" that will show 2 lists, the users that haven't voted yet as well as the users that have voted ( I actually added both just in case you where it was easier for you to simply get the emails of each list separately and with more ease :slight_smile: ).

    How to install:
    Always make sure to keep a backup of your site before changing/adding custom code.

    1] Navigate to your /wp-content/ directory and create a new one named mu-plugins if it doesn't exist.
    2] Inside the mu-plugins folder create a file named forminator-custom-poll-users.php
    3] Edit the file and copy / paste this code snippet inside.

    <?php
    
    /**
     * Plugin Name: Forminator - Gather users that voted ( Poll Users ).
     * Plugin URI: https://premium.wpmudev.org/
     * Description: mu-plugin that adds a custom option and admin screen to show who voted on a Poll.
     * Version: 1.0.0
     * Author: Konstantinos Xenos @ WPMUDEV
     * Author URI: https://premium.wpmudev.org/
     * License: GPLv2 or later
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    }
    
    if ( ! class_exists( 'WPMUDEV_Forminator_Custom_Poll_Users' ) ) {
    
    	/**
    	 * WPMUDEV_Forminator_Custom_Poll_Users Class.
    	 */
    	class WPMUDEV_Forminator_Custom_Poll_Users {
    
    		/**
    		 * Constructor.
    		 */
    		public function __construct() {
    			add_action( 'init', array( $this, 'create_menus' ) );
    			add_action( 'forminator_polls_after_handle_submit', array( $this, 'poll_submitted' ) );
    		}
    
    		/**
    		 * Creates the Admin Menus.
    		 */
    		public function create_menus() {
    			add_action( 'admin_menu', array( $this, 'populate_admin_menu' ) );
    		}
    
    		/**
    		 * Populate the admin menus.
    		 */
    		public function populate_admin_menu() {
    			add_menu_page(
    				esc_html__( 'Poll Users', 'custom-poll-users' ),
    				esc_html__( 'Poll Users', 'custom-poll-users' ),
    				'manage_options',
    				'custom-poll-users',
    				array( $this, 'create_page' ),
    				'dashicons-feedback'
    			);
    		}
    
    		/**
    		 * Create the Admin page.
    		 */
    		public function create_page() {
    			global $wpdb;
    
    			$users_with_vote = get_option( 'custom_poll_users', array() );
    			$all_users       = $wpdb->get_results( "SELECT ID FROM {$wpdb->users}" );
    			$all_users_ids   = array();
    
    			foreach ( $all_users as $_user ) {
    				array_push( $all_users_ids, $_user->ID );
    			}
    
    			$users_without_vote = array_diff( $all_users_ids, $users_with_vote );
    			?>
    			<div class="wrap">
    				<h1><?php esc_attr_e( 'Poll Users', 'custom-poll-users' ); ?></h1>
    				<br class="clear" />
    				<div style="display:grid;grid-template-columns: repeat( 2, 1fr );grid-gap: 20px;">
    					<div>
    						<h2><?php esc_attr_e( 'Users that did not vote', 'custom-poll-users' ); ?></h2>
    						<table class="widefat">
    							<thead>
    							<tr>
    								<th><?php esc_attr_e( 'ID', 'custom-poll-users' ); ?></th>
    								<th><?php esc_attr_e( 'Username', 'custom-poll-users' ); ?></th>
    								<th><?php esc_attr_e( 'E-mail', 'custom-poll-users' ); ?></th>
    							</tr>
    							</thead>
    							<tbody>
    							<?php
    							if ( ! empty( $users_without_vote ) ) {
    								foreach ( $users_without_vote as $key => $user_id ) {
    									$user_data = get_userdata( $user_id );
    									?>
    									<tr>
    									<td><?php echo esc_attr( $user_id ); ?></td>
    									<td><?php echo esc_attr( $user_data->user_login ); ?></td>
    									<td><?php echo esc_attr( $user_data->user_email ); ?></td>
    									</tr>
    									<?php
    								}
    							} else {
    								?>
    								<tr>
    								<td colspan="3"><?php esc_attr_e( 'There are no users to show.', 'custom-poll-users' ); ?></td>
    								</tr>
    								<?php
    							}
    							?>
    							</tbody>
    							<tfoot>
    							<tr>
    								<th><?php esc_attr_e( 'ID', 'custom-poll-users' ); ?></th>
    								<th><?php esc_attr_e( 'Username', 'custom-poll-users' ); ?></th>
    								<th><?php esc_attr_e( 'E-mail', 'custom-poll-users' ); ?></th>
    							</tr>
    							</tfoot>
    						</table>
    					</div>
    					<div>
    						<h2><?php esc_attr_e( 'Users that voted', 'custom-poll-users' ); ?></h2>
    						<table class="widefat">
    							<thead>
    							<tr>
    								<th><?php esc_attr_e( 'ID', 'custom-poll-users' ); ?></th>
    								<th><?php esc_attr_e( 'Username', 'custom-poll-users' ); ?></th>
    								<th><?php esc_attr_e( 'E-mail', 'custom-poll-users' ); ?></th>
    							</tr>
    							</thead>
    							<tbody>
    							<?php
    							if ( ! empty( $users_with_vote ) ) {
    								foreach ( $users_with_vote as $key => $user_id ) {
    									$user_data = get_userdata( $user_id );
    									?>
    									<tr>
    									<td><?php echo esc_attr( $user_id ); ?></td>
    									<td><?php echo esc_attr( $user_data->user_login ); ?></td>
    									<td><?php echo esc_attr( $user_data->user_email ); ?></td>
    									</tr>
    									<?php
    								}
    							} else {
    								?>
    								<tr>
    								<td colspan="3"><?php esc_attr_e( 'There are no users to show.', 'custom-poll-users' ); ?></td>
    								</tr>
    								<?php
    							}
    							?>
    							</tbody>
    							<tfoot>
    							<tr>
    								<th><?php esc_attr_e( 'ID', 'custom-poll-users' ); ?></th>
    								<th><?php esc_attr_e( 'Username', 'custom-poll-users' ); ?></th>
    								<th><?php esc_attr_e( 'E-mail', 'custom-poll-users' ); ?></th>
    							</tr>
    							</tfoot>
    						</table>
    					</div>
    				</div>
    			</div>
    			<?php
    		}
    
    		/**
    		 * Updated the custom option when a poll is submitted.
    		 */
    		public function poll_submitted( $form_id ) {
    			$user_id = get_current_user_id();
    
    			// Run if there's a user logged in.
    			if ( 0 !== $user_id ) {
    				$option = get_option( 'custom_poll_users', array() );
    				array_push( $option, $user_id );
    				$updated_option = array_unique( $option );
    				update_option( 'custom_poll_users', $updated_option );
    			}
    		}
    	}
    
    	new WPMUDEV_Forminator_Custom_Poll_Users();
    }

    4] Save and close the file.
    5] The final path should look like /wp-content/mu-plugins/forminator-custom-poll-users.php
    6] Everything should work after that automatically.

    Note that the IDs will start getting gathered after this code is added, unfortunately all previous votes won't be able to be verified as well as that this will work for "any Poll" at the moment, so if you have more than 1 active on the site tell me so I can update the code to help out more :slight_smile: .

    Tell me if you need any further help or customization with this.

    Regards,
    Konstantinos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.