Wordpress创建新用户并发布发布

问题描述

我正在创建一个用户服务提供商的网站。该网站具有两个主要角色:用户和供应商。要成为供应商,任何人都可以在网站上填写表格,这将创建一个具有供应商角色的新用户。该用户正在等待审核,直到得到管理员的批准。 我现在想做的是以下事情:

每次注册(或批准)新供应商时,都应创建一个新帖子,其中包含供应商的数据,因此可以轻松地将其拉到前端配置文件存档页面中。

我已经尝试过在类似线程中找到的这段代码

add_action( 'user_register','newUserPost',10,1 );

function newUserPost( $user_id )
{
    // Get user info
    $user_info = get_userdata( $user_id );
    $user_roles = $user_info->roles; 
    $this_user_role = implode(',',$user_roles );

    if ($this_user_role == 'vendor') {

        // Create a new post
        $user_post = array(
            'post_title'   => $user_info->nickname,'post_status'  => 'publish',// <- here is to publish
            'post_type'    => 'Influencer',// <- change to your cpt
        );
        // Insert the post into the database
        $post_id = wp_insert_post( $user_post );
    }
}

但是在创建新的供应商之后,什么也没有发生。

如果有人能指出正确的方向,我将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...