• Resolved shahifits

    (@shahifits)


    <?php
    
    add_filter(
    	'forminator_render_form_markup',
    	function( $html, $form_fields, $form_type, $form_settings, $form_design, $render_id ) {
    		if ( is_user_logged_in() ) {
    			global $wpdb;
    			$user_id_field_name = 'hidden-1';
    			$user_id            = get_current_user_id();
    			$message            = __( 'You can submit this form only once' );
    
    			$user_entries = $wpdb->get_var(
    				$wpdb->prepare(
    					"SELECT COUNT(e.entry_id) FROM {$wpdb->prefix}frmt_form_entry as e
    					INNER JOIN {$wpdb->prefix}frmt_form_entry_meta as m ON e.entry_id=m.entry_id
    					WHERE m.meta_key=%s AND m.meta_value=%d 
    					LIMIT 1",
    					$user_id_field_name,
    					$user_id
    				)
    			);
    
    			if ( ! empty( $user_entries ) || 0 < $user_entries ) {
    				return $message;
    			}
    		}

    I have checked this code. This code is running but this script is running for just 1 time form submission. I want that same script to 4 times then say something to the user that you are not allowed to fill the form 5 time.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @shahifits

    I hope you’re well today!

    Please replace value of 0 in this line

    if ( ! empty( $user_entries ) || 0 < $user_entries ) {

    with value of 3, so the line becomes

    if ( ! empty( $user_entries ) || 3 < $user_entries ) {

    This should do the trick.

    Best regards,
    Adam

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @shahifits,

    Since we haven’t heard from you for a while. I’ll mark this thread as resolved for now. Please feel free to re-open the thread if you need further assistance.

    Best Regards
    Nithin

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Limit User Submission To Max 4 Submits Per Id (Not IP)’ is closed to new replies.