dprq18175 2018-12-14 21:14
浏览 46
已采纳

重力形式限制提交金额

so i currently have gravity forms installed with a number of different forms. I want users to be able to see all the forms but only able to submit a maximum of 3. I found Gravity Wiz Limit submissions, im able to limit the email address to being used 3 times but this is only working for 1 form, i need it to allow users to submit 3 different forms (eg. a global limitation)

https://gist.github.com/spivurno/4024361

having looked through this and then finding

add_filter( 'gpls_rule_groups', function( $rule_groups, $form_id ) {
    // Update "123" to the ID of your form.
    $primary_form_id = 123;
    if( $form_id == $primary_form_id ) {
        return $rule_groups;
    }
    $rule_groups = array_merge( $rule_groups, GPLS_RuleGroup::load_by_form( $primary_form_id ) );
    foreach( $rule_groups as $rule_group ) {
        $rule_group->applicable_forms = false;
    }
    return $rule_groups;
}, 10, 2 );

and

add_filter( 'gpls_apply_limit_per_form', '__return_false' );

it looks like its possible but how can i implement this ?

  • 写回答

1条回答 默认 最新

  • douyue7408 2018-12-19 14:55
    关注

    Is it for a user or guest or both? By user you could create a user meta and then use the gform_after_submission to add to the meta. Then use a pre_render to check and see if they are maxed out, and redirect them if they are.

    add_action( 'gform_after_submission_{form_id}', 'after_submit_{form_id}', 10, 2 );
    function after_submit_{form_id}( $entry, $form, $field ) {
    
    $user_id = get_current_user_id();
    $meta_key = 'count_submissions';
    
    $get_meta = get_user_meta($user_id, $meta_key, true);
    $qty = $get_meta + 1;
    
    update_user_meta( $user_id, $meta_key, $qty );
    }
    

    If you need both, you might just create a database table and collect IPs and a submission count. Then update that on submission.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵