doudichu1358 2016-06-23 07:15
浏览 53
已采纳

如何通过php编程为wordpress创建作者?

Is there anyone who has the idea that how to create authors for wordpress by php programmatically?

  • 写回答

1条回答 默认 最新

  • douquanjie9326 2016-06-23 07:20
    关注

    Try this

    $user_id = username_exists( $user_name );
    if ( !$user_id and email_exists($user_email) == false ) {
        $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
        $user_id = wp_create_user( $user_name, $random_password, $user_email );
        wp_update_user(array(
            'ID' => $user_id,
            'role' => 'Author'
        ));
    } else {
        $random_password = __('User already exists.');
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具
  • ¥15 安装虚拟机时出现问题
  • ¥15 Selenium+docker Chrome不能运行
  • ¥15 mac电脑,安装charles后无法正常抓包
  • ¥18 visio打开文件一直显示文件未找到
  • ¥15 请教一下,openwrt如何让同一usb储存设备拔插后设备符号不变?