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.

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

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算