Logged-Users Submit Button

By: Raymond Ringston | Asked: 03/14/2023
ForumsCategory: Paid Help WantedLogged-Users Submit Button
Raymond Ringston asked 1 year ago
I need a polls form created that will allow only logged-in users to vote in. I want the poll visible to non-users, but the submit button is inactive.
Bobby Clapp replied 1 year ago

I don't know of a simple or example solution for this. Custom code can surely do something for you. Let me ask a question though. How does a non-user know how to submit the form. Are you going to write up some text?

A version of this code can put in place a class that you could then disable with JS/JQuery: https://formidableforms.com/knowledgebase/frm_submit_button_class/#kb-add-a-class-to-a-single-submit-button

Maybe something this:
add_filter('frm_submit_button_class', 'add_submit_class', 10, 2);
function add_submit_class( $classes, $form ){
if ( $form->id == 123 ) {
if ( is_user_logged_in() ) {
$classes[] = 'my-custom-enabled-class';
} else {
$classes[] = 'my-custom-disabled-class';
}
}
return $classes;
}

Then maybe something like this:
jQuery(function(){
jQuery("input.my-custom-disabled-class").attr("disabled", true);
});

Raymond Ringston replied 1 year ago

Yes, the goal is to have the poll visible on a post directing viewers to login to vote. I was hoping it could be done using conditional logic within the buttons field.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right