• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Programming / wp_insert_user() with “no role for this site”

wp_insert_user() with “no role for this site”

Last updated on December 19, 2013 by Sal Ferrarello

My goal was to use wp_insert_user() to create a user with “no role for this site”.  For some notes on “no role for this site” see http://wordpress.org/support/topic/what-exactly-is-no-role-for-this-site-do#post-2177545

When using

$new_user = wp_insert_user( $userdata );

omitting the role parameter in the $userdata uses the default role set.

If you want “no role for this site”, set the role to an empty string.

// assign $userdata here as per the codes

// set role to an empty string

$userdata[‘role’] = ”;

$new_user = wp_insert_user( $userdata );

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit

Filed Under: Programming Tagged With: WordPress, WordPress Plugin

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in