提交Pionetforms之后的角色更改
我想设置订户提交表格,那么角色将从订户更改为客户。
供您参考,我正在与您分享Pionetforms的动作钩和滤镜: https://piotnetforms.com/docs/com/actions/actions-hook-filter-hook/ < /a>
我已经搜索过并找到了一些代码源,但是我不知道如何使用PionetForms。
add_action('cred_save_data', 'change_user_role_on_save',10,2);
function change_user_role_on_save($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==573)
{
$user = wp_get_current_user();
if ( in_array( 'subscriber', (array) $user->roles ) ) {
// Remove role
$user->remove_role( 'subscriber' );
// Add role
$user->set_role('customer');
}
}
}
当前使用成员Press制造的“成员”插件。
如果有人让我知道如何解决它,我会很感激。 谢谢。
I would like to set up if subscribers submit a form then the role is changed from subscriber to customer.
For your reference, I am sharing with you the Pionetforms' action hook and filter hook:
https://piotnetforms.com/docs/actions-hook-filter-hook/
I have googled and found some code sources, but I have no clue how to work with Pionetforms.
add_action('cred_save_data', 'change_user_role_on_save',10,2);
function change_user_role_on_save($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==573)
{
$user = wp_get_current_user();
if ( in_array( 'subscriber', (array) $user->roles ) ) {
// Remove role
$user->remove_role( 'subscriber' );
// Add role
$user->set_role('customer');
}
}
}
Currently using "members" plugin which is made by memberpress.
I would be grateful if anyone let me know how to solve it.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个代码:
您可以更改 formname1、formname2、formname3、formname4
Here is a code:
You can chagne formname1, formname2, formname3, formname4