子比主题实名认证功能[新功能]

使用WordPress做个一个现代化的优质网站,与用户的交互功能必须的全面,zibll子比主题V6更新后带来了全新的用户身份认证功能。本人在此功能的启发之下,写了zibll子比主题全新的用户实名认证功能(注意:目前仅支持个人实名)

此功能为技术猿二次开发功能!

功能介绍

首先我们还是简单的讲解一下zibll子比主题用户实名认证的功能以及特点:

  • 操作简单,主题设置一键开启即可(默认开启)
  • 支持单独开启或者关闭申请通道
  • 支持用户在前台发起认证申请
  • 对接腾讯云实名三要素接口实时返回数据
  • 支持管理员在后台手动设置用户的实名认证

功能设置

此功能设置,就十分简单了。
进入主题设置->用户&功能->实名认证:开启此功能即可!

图片[1]-子比主题实名认证功能

前台发起认证申请

用户可以在用户中心->实名认证发起认证申请,或者查看自己的实名认证详情 (注意:申请之前,请先绑定手机号)

图片[2]-子比主题实名认证功能

后台手动设置

除了用户申请,管理员审核之外呢,管理员还可以在后台手动的将某一个用户设置为实名认证用户
进入WordPress后台->用户:选择用户点击编辑

图片[3]-子比主题实名认证功能

核心代码

后台设置代码

CSF::createSection($prefix, array(
    'parent'      => 'user',
    'title'       => '实名认证' . $new_badge['7.3'],
    'icon'        => 'fa fa-fw fa-bullseye',
    'description' => '',
    'fields'      => array(
        array(
            'content' => '<p>此功能(实名认证)为技术猿二次开发项目</p>
                <div style="margin:10px 14px;"><li>技术猿官网:<a target="_bank" href="https://www.zbape.com/">https://zbape.com</a></li>
                <li>作者联系方式:<a target="_bank" href="http://wpa.qq.com/msgrd?v=3&uin=1660047787&site=qq&menu=yes">QQ 1660047787</a></li>
                </div>',
            'style'   => 'warning',
            'type'    => 'submessage',
        ),
        array(
            'title'   => __('启用用户实名认证', 'zib_language'),
            'id'      => 'user_auths',
            'type'    => 'switcher',
            'default' => false,
        ),
        array(
            'id'      => 'person_user_auths',
            'default' => 'tencent',
            'title'   => '个人主体实名接口',
            'type'    => "select",
            'options' => array(
                //'alipay'     => __('支付宝(三要素)', 'zib_language'),
                'tencent'    => __('腾讯云(三要素)', 'zib_language'),
            ),
        ),
        array(
            'title'      => '申请实名认证设置',
            'id'         => 'auths_option',
            'type'       => 'fieldset',
            'fields'     => array(
                array(
                    'title'   => __('允许用户申请', 'zib_language'),
                    'id'      => 's',
                    'type'    => 'switcher',
                    'default' => true,
                ),
                array(
                    'dependency' => array('s', '==', ''),
                    'title'      => __('停用说明', 'zib_language'),
                    'desc'       => '',
                    'id'         => 'disable_desc',
                    'default'    => '由于系统正在维护,暂时无法申请实名认证<br/>
详情请联系管理员',
                    'sanitize'   => false,
                    'type'       => 'textarea',
                    'attributes' => array(
                        'rows' => 3,
                    ),
                ),
                array(
                    'dependency' => array('s', '!=', ''),
                    'title'      => __('申请介绍', 'zib_language'),
                    'desc'       => '用户申请认证的时候显示的介绍内容',
                    'id'         => 'desc',
                    'default'    => '<div class="ml10">
  <li>实名用户会在昵称后显示实名徽章,同时享受多种优先待遇</li>
  <li>申请认证请确保信息属实,提交申请后会自动与官方数据进行对比</li>
  <li class="c-red">如非本人手机号,请先更换绑定手机,手机号实名制信息必须与身份证号码一致</li>
<li class="c-red">你的真实信息仅用于实名认证,并受到平台加密保护,请放心认证。<a href="https://flk.npc.gov.cn/detail2.html?MmM5MDlmZGQ2NzhiZjE3OTAxNjc4YmY4Mjc2ZjA5M2Q%3D" target="_blank" class="ml-2">相关法律法规原文</a></li>
</div>',
                    'sanitize'   => false,
                    'type'       => 'textarea',
                    'attributes' => array(
                        'rows' => 3,
                    ),
                ),
            ),
        ),
        array(
            'title'    => '腾讯云三要素核验',
            'subtitle' => '接口配置',
            'id'       => 'auths_sdk_zbape',
            'type'     => 'fieldset',
            'fields'   => array(
                array(
                    'content' => '申请地址:<a target="_blank" href="https://market.cloud.tencent.com/products/5289">腾讯云市场-手机三要素核验</a>',
                    'style'   => 'info',
                    'type'    => 'submessage',
                ),
                array(
                    'title' => 'SecretID',
                    'id'    => 'secretid',
                    'type'  => 'text',
                ),
                array(
                    'title' => 'SecretKey',
                    'class' => 'secretkey',
                    'id'    => 'secretkey',
                    'type'  => 'text',
                ),
            ),
        ),
    )));

后台修改用户实名信息代码

if (_pz('user_auths', false)) {

        CSF::createProfileOptions('user_auths', array(
            'data_type' => 'unserialize',
        ));

        CSF::createSection('user_auths', array(
            'fields' => array(
                array(
                    'type'    => 'content',
                    'content' => '<h3>实名认证</h3><p>手动设置用户的实名认证信息</p>',
                ),
                array(
                    'title'   => __('已实名用户', 'zib_language'),
                    'id'      => 'auths',
                    'type'    => 'switcher',
                    'default' => false,
                ),
                array(
                    'dependency' => array('auths', '!=', ''),
                    'title'      => ' ',
                    'subtitle'   => '实名信息',
                    'id'         => 'auths_info',
                    'type'       => 'fieldset',
                    'class'      => 'compact',
                    'fields'     => array(
                        array(
                            'title' => '实名类型',
                            'id'      => 'types',
                            'default' => 'null',
                            'type'    => "select",
                            'options' => array(
                                'null'     => __('未实名', 'zib_language'),
                                'person'     => __('个人实名', 'zib_language'),
                                //'enterprise'    => __('企业实名', 'zib_language'),
                            ),
                        ),
                        array(
                            'title' => '主体名称',
                            'class' => 'compact',
                            'id'    => 'names',
                            'type'  => 'text',
                        ),
                        array(
                            'title' => '证件号码',
                            'class' => 'compact',
                            'id'    => 'idcard',
                            'type'  => 'text',
                        ),
                        array(
                            'title' => '联系号码',
                            'class' => 'compact',
                            'id'    => 'iphone',
                            'type'  => 'text',
                        ),
                        array(
                            'title'    => '认证时间',
                            'id'       => 'time',
                            'type'     => 'date',
                            'desc'       => '<div class="c-red"><i class="fa mr6 fa-info-circle"></i>注意事项:后台设置数据不会存入数据库,可能会二次认证</div>',
                            'default'  => current_time('Y-m-d H:i'),
                            'settings' => array(
                                'dateFormat'  => 'Y-m-d H:i',
                                'changeMonth' => true,
                                'changeYear'  => true,
                            ),
                        ),
                    ),
                ),
            ),
        ));
    }

用户个人中心菜单

if (_pz('user_auths', false)) {
        $tabs_array['auths'] = array(
            'title'    => '实名认证',
            'nav_attr' => 'drawer-title="实名认证"',
            'loader'   => '<div style="padding: 40px 20px;" class="colorful-bg c-blue flex jc zib-widget"><div class="colorful-make"></div><div class="text-center"><div class="em4x"><svg class="icon" aria-hidden="true"><use xlink:href="#icon-user-auths"></use></svg></div><div class="mt10 em14 padding-w10 font-bold mb40">实名认证</div><div class="placeholder" style="width: 120px;height: 30px;">  </div></div></div>',
        );
    }
if (_pz('user_auths', false)) {
        $buttons[] = array(
            'html' => '',
            'icon' => zbape_auths_icon(),
            'name' => '实名认证',
            'tab'  => 'auths',
        );
    }

注意事项

  • 只写了个人实名,如需企业实名可自行开发
  • 不建议后台修改用户实名认证,可能会造成二次认证
© 版权声明
THE END
喜欢就支持一下吧
点赞19赞赏 分享
评论 共4条

请登录后发表评论

    请登录后查看评论内容