loehoafaq
Forum Replies Created
-
That was the problem. I wonder how it came to be inactivated? Can this happen automatically in response to an error condition?
In any event, thanks again for your help!
I installed the new version in the same directory the previous version was in, and moved the original to a different directory. I still don’t see the codes in Settings => Appearance => Registration Form.
I installed UM 2.8.4 and it still doesn’t work. Is there anything else I need to do?
Just wanted to say that I used the new plugin for registering the 200+ members of our homeowners association and it worked perfectly. It’s a simple, easy-to-manage way of ensuring that only members of a group are able to register. I generated random codes with > 8×10^17 possible values and used Word’s mail merge feature to print a custom letter for each owner.
Even older, non-computer-savvy owners said registering was easy.
Thanks for your help.
I found the xx_poll_users records in the wp_options table in the WordPress db. If I wanted to start a poll over, could I do this by deleting the corresponding record? Is there any other cleanup needed? Or can this be done from the WP admin interface?
Are detailed results available, preferably in an anonymous but per-vote form, so we can export to a spreadsheet and do custom analysis?
Is the schema for poll data available?
That’s great. When not logged in, the user sees a message saying “You must be logged in to vote in this poll.” instead of the “Vote” button.
Logged in users see the “Vote” button. If a user who hasn’t voted before clicks on the “Vote” button their vote is counted and the current results are displayed (which is how I configured this poll). If they have voted before they see instead “You have already submitted a vote to this poll” at the top of the poll.
This achieves my goal of allowing only logged in users to vote, and then only once. It would be even better if the “You have already submitted a vote to this poll” could be displayed without the user having to make selections and submit the poll. Our website is for a homeowners association, and each household gets one vote on each issue. As a result, user IDs will be shared by spouses. Some of our polls will be quite long; if we told users they’d already vote before they start filling out the poll it could save them both time and annoyance when their spouse has already voted for their household.
Might that be possible?
I can prevent non-registered users from voting by restricting rendering with [um_show_content =’ list of user roles’] as I’m doing on other pages. I didn’t because then you wouldn’t have been able to see it.
Where in the database can I find the data showing which users have voted in any given poll? Perhaps that would be enlightening?
Solved. I implemented your ‘Registration Code’ mu-plugin and it was working. In the process of looking at everything tonight I noticed all the registration codes at the bottom of the Appearance=>Registration Form page were gone. No idea how that happened.
I pasted them back in and the Login form displays properly now.
Wouldn’t have thought the two could be related, but apparently so.
Gotta love a happy ending!
Test Methodology
- I created a new poll (forminator_poll id=”260″), verified that it works properly, then duplicated it (forminator_poll id=”266″).
- I followed the provided instructions to add the following code to a mu-plugins php file with the correct permissions.
<?php add_filter( 'forminator_poll_handle_form_user_can_vote', 'wmudev_check_user_submission_poll', 10, 2 ); function wmudev_check_user_submission_poll( $user_can_vote, $module_id ) { if ( $module_id != 266 ) { // Only apply filter to copy of test poll return $user_can_vote; } // if ( !is_user_logged_in() ) { // return $user_can_vote; // } if ( !is_user_logged_in() ) { // only logged-in users can vote $user_can_vote = false; throw new Exception( esc_html__( 'You must be logged in to vote in this poll', 'forminator' ) ); return $user_can_vote; } $user_id = get_current_user_id(); // get logged-in user's user_id $users_with_vote = get_option( $module_id.'_poll_users', array() ); // get list of those who have previously voted in this poll if ( ! empty( $users_with_vote ) ) { if ( in_array( $user_id, $users_with_vote ) ) { // if logged-in user is in that list... $user_can_vote = false; // they can't vote again throw new Exception( esc_html__( 'You have already submitted a vote to this poll', 'forminator' ) ); } } return $user_can_vote; } add_action( 'forminator_poll_after_handle_submit', 'wpmudev_record_user_poll_submission', 10, 2 ); add_action( 'forminator_poll_after_save_entry', 'wpmudev_record_user_poll_submission', 10, 2 ); function wpmudev_record_user_poll_submission( $module_id, $response ) { // if ( $module_id != 230 ) { //Please change the poll ID // return; // } if ( is_user_logged_in() ) { $user_id = get_current_user_id(); // get user_id $option = get_option( $module_id.'_poll_users', array() ); // get array of those who have already voted in this poll array_push( $option, $user_id ); // add user_id to the array $updated_option = array_unique( $option ); // update the array update_option( $module_id.'_poll_users', $updated_option ); } }
- I then embedded the short codes for the polls in this page:
https://liveoakestateshoa.com/test-poll-page/
Neither is rendered correctly.
If I move my php file out of the mu-plugins directory, both render correctly.
I’ve left the php file in the mu-plugins directory so you can see what happens.
What additional information can I provide to help debug this?
Thanks!
I have a couple of questions
- Am I correct in thinking module_id is passed in as the id of the current poll by forminator, and if I want every poll to be treated this way I can just remove the check for a specific value [if ( $module_id != 230 )]?
- Since I only want logged in users who haven’t previously voted to be able to vote, wouldn’t I want to modify the code as follows to exclude those who are not logged in?
- if (!is_user_logged_in()) { return false;}
- Although I’m a programmer, I’m a rank amateur when it comes to WordPress hooks. Will these functions be automatically called for each poll or must I add something to cause that to happen?
- Other than observing the behavior of my polls when I test this, is there any log file I should examine for evidence of what’s happening?
Thanks very much for your reply and the effort you put into this. I’ll try it tomorrow and let you know how it goes.
Thanks, Adam. Look forward to your reply. I’ve set up an Astra child theme in which I’ve already got some custom code, so adding more would be a feasible solution for me.
And is there a way to AUTOMATICALLY remove each code after it has been used to successfully register once?
I’ve posted a support topic on the wpForo page that you may want to follow and chime in on when desired.
https://wpforo.com/community/how-to-and-troubleshooting-2/polls-not-rendering-properly-in-wpforo/
wpForo allows custom CSS to be added; if it’s a CSS problem it shouldn’t be difficult to test any proposed solution.
Thanks!
Thanks, Patrick. I finally found an option buried deep in the wpForo settings (wpForo->Settings>Posting & Editor Settings->Enable WordPress Shortcodes in Post Content that is turned off by default. Enabling it causes the poll to be rendered. As noted in another post, it’s not rendered properly. This problem and the other don’t seem to have a common cause.
Forum: Plugins
In reply to: [wpForo Forum] Forminator polls are not being renderedPartially fixed. Found the wpForo setting to enable processing of short codes and turned it on. Now my poll appears but is mis-rendered. I’ve submitted a support request on the Forminator forum.
wpForo->Settings->Posting & Editor Settings then scroll WAY down on the page to “Enable WordPress Shortcodes in Post Content” and turn it on.