Title: Register user programmatically
Last modified: January 17, 2025

---

# Register user programmatically

 *  [islp](https://wordpress.org/support/users/islp/)
 * (@islp)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/register-user-programmatically/)
 * If I register a user programmatically, will wp-members approval still work?

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Chad Butler](https://wordpress.org/support/users/cbutlerjr/)
 * (@cbutlerjr)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/register-user-programmatically/#post-18250645)
 * Yes – the user meta that determines if they are activated is set when they are
   activated (or updated when they are deactivated).
 *  Thread Starter [islp](https://wordpress.org/support/users/islp/)
 * (@islp)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/register-user-programmatically/#post-18250654)
 * [@cbutlerjr](https://wordpress.org/support/users/cbutlerjr/) ok, but my users
   are not active by default. So the question is: will I bypass wpm approval if 
   I register a user programmatically?
    -  This reply was modified 1 year, 4 months ago by [islp](https://wordpress.org/support/users/islp/).
 *  Thread Starter [islp](https://wordpress.org/support/users/islp/)
 * (@islp)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/register-user-programmatically/#post-18274059)
 * [@cbutlerjr](https://wordpress.org/support/users/cbutlerjr/) sorry for the late
   reply, I’ve been very busy. 🙁 Ok: I found a user registered programmatically
   is NOT active by default.
 * So, my question is: is there any way to bypass this setting? Basically, I would
   like to have programmatically registered users be directly active.
 * Is there a wp_members usermeta where the user’s status is recorded? I could also
   change the user status from there, perhaps.
 * [EDIT] Ok, I found wp-members sets an ‘active’ usermeta with value 0 or 1. When
   I update_user_meta setting active=1, the Users table reflects this change and
   it doesn’t display the Activate label anymore. Usermeta update by code does not
   cause unwanted activation emails to be sent (perfect!) 🙂
   Please, let me know
   if you have any comment, that is if I’m missing something important here.
    -  This reply was modified 1 year, 4 months ago by [islp](https://wordpress.org/support/users/islp/).
 *  Plugin Author [Chad Butler](https://wordpress.org/support/users/cbutlerjr/)
 * (@cbutlerjr)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/register-user-programmatically/#post-18275426)
 * Sorry – I misunderstood your original question (or actually, didn’t understand
   which direction you were going with this).
 * If you set a user meta value of “active” as “1” when you create the user, they
   will be created as already active.
 * The best approach would be to use the plugin’s API function [`wpmem_activate_user()`](https://rocketgeek.com/plugins/wp-members/docs/api-functions/wpmem_activate_user/).
   This allows you the most forward compatible (should the meta ever have a change).
   That function allows you to not only activate the user, but to determine if the
   notification email to the user should be sent. The email is sent by default, 
   so if you want them to not be notified, you would do it as follows:
 * `wpmem_activate_user( $user_id, false );`
 * where $user_id is the user ID being activated.
 *  Thread Starter [islp](https://wordpress.org/support/users/islp/)
 * (@islp)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/register-user-programmatically/#post-18275571)
 * Hi [@cbutlerjr](https://wordpress.org/support/users/cbutlerjr/), thanks for your
   detailed reply. One more question: from my plugin, is there anything I can do
   to check if wp_members is installed and working? I could check for its presence
   before calling wpmem_activate_user
 *  Plugin Author [Chad Butler](https://wordpress.org/support/users/cbutlerjr/)
 * (@cbutlerjr)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/register-user-programmatically/#post-18275686)
 * You could check if `$wpmem` is an object.
 * Or (probably best), check if `wpmem_activate_user()` exists as a function (i.
   e. `if ( function_exists( 'wpmem_activate_user' ) ) ...`
 *  Thread Starter [islp](https://wordpress.org/support/users/islp/)
 * (@islp)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/register-user-programmatically/#post-18276411)
 * [@cbutlerjr](https://wordpress.org/support/users/cbutlerjr/) fantastic, thanks
   🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Register user programmatically’ is closed to new replies.

 * ![](https://ps.w.org/wp-members/assets/icon-256x256.png?rev=1226414)
 * [WP-Members Membership Plugin](https://wordpress.org/plugins/wp-members/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-members/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-members/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-members/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-members/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-members/reviews/)

## Tags

 * [admin](https://wordpress.org/support/topic-tag/admin/)
 * [approval](https://wordpress.org/support/topic-tag/approval/)
 * [new](https://wordpress.org/support/topic-tag/new/)
 * [users](https://wordpress.org/support/topic-tag/users/)

 * 7 replies
 * 2 participants
 * Last reply from: [islp](https://wordpress.org/support/users/islp/)
 * Last activity: [1 year, 4 months ago](https://wordpress.org/support/topic/register-user-programmatically/#post-18276411)
 * Status: not resolved