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 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接
  • ¥15 MATLAB中使用parfor,矩阵Removal的有效索引在parfor循环中受限制
  • ¥20 Win 10 LTSC 1809版本如何无损提升到20H1版本
  • ¥50 win10 LTSC 虚拟键盘不弹出
  • ¥30 微信小程序请求失败,网页能正常带锁访问
  • ¥15 Matlab求解微分方程,如何用fish2d进行预优?