Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Cannot select signup_meta upon multisite user activation

Alright, finally I sorted it out – and it was a query error (embarrassing it is).

Correct code:

add_action( 'wpmu_activate_user', 'promote_to_admin', 99 );
function promote_to_admin( $user_id, $password, $meta ) {
    global $wpdb;
    $user = get_userdata( $user_id );
    $email = $user->user_email;
    // You need to prepare query first to avoid SQL errors
    $query = $wpdb->prepare( "SELECT meta from `wp_signups` where `user_email` = %s", $email );
    // By default, Object(stdClass) will be returned; 
    // tell WordPress to convert it to multidimensional array
    $raw_meta = $wpdb->get_results( $query, ARRAY_A );
    // After conversion, array will be represented as serialized string - unserialize it
    $signup_meta = unserialize( $raw_meta[0]['meta'] );
    if ( array_key_exists( 'new_role', $signup_meta ) ) {
        $user->set_role( $signup_meta['new_role'] );
    }
}

Related Posts:

  1. How do I remove/delete an old super admin user?
  2. Why is WordPress Multisite redirecting to wp-signup.php and how to fix it?
  3. Is there any central control/access panel for several WordPress sites?
  4. Delete sites in wordpress multisite (not suspend)
  5. How to synchronize user profile fields in multisite?
  6. How to customize the wp-signup.php for a multisite network?
  7. Get first_name and last_name on user_register hook
  8. User registration on subsite in multisite configuration
  9. Lock one of WP Network sites for not registered users
  10. Can you have multi-site WP and keep users separate?
  11. Multisite Independent User Base
  12. Why wordpress multisite redirect to wp-signup if site exists?
  13. Can wp-cli display all users and their roles across all sites in a multisite instance?
  14. How do I use different domain for subdomains in WP Multisite?
  15. Deleting a user in multisite
  16. how do I configure nginx for wordpress multisite, it occurs ERR_TOO_MANY_REDIRECTS
  17. Stuck with WordPress Multisite Custom signup page without .htaccess modification
  18. How do I list multisite users for the current site only
  19. Assign role to user on first login, if they are first (after admin)
  20. How to change user starting role in WordPress MultiSite?
  21. What is meant by Multisite in WordPress?
  22. Add menu items/actions for multisite users who are registered on the network but do not have a role or capability in any sites
  23. Multisite User Sync Question about blog authorship
  24. Preferred method of setting user role only works on Main Site in Network
  25. Register existing user on another site in a multisite network?
  26. Subsite access without being a member of the subsite in wp multisite network
  27. Site redirecting to http://example.com/wp-signup.php?new=example.com
  28. single sign on for wordpress multi site
  29. Multi-Site Subfolder User Permission Issue
  30. I want to create a 300 multi-site wordpress network using subdomains
  31. Network of multisites in WordPress, create new site with all the contents of the main
  32. how to create wordpress network with multiple wordpress installations
  33. WordPress multisite, allow non super admins to create sites
  34. User registration is currently not allowed
  35. Change WP-LOGIN and WP-SIGNUP for any request
  36. How to clone homepage for multi region site?
  37. Automatically add a registered user on the wordpress multisite network even to just one other site
  38. Easily adding multiple existing users to a multisite site
  39. Allowing users to manually add or remove themselves to/from WordPress multisite blogs
  40. WordPress API – sign-up to multiple Multisites from one single form
  41. Is there any hook to validate google recaptcha dislayed in wp-signup page [in WordPress Multisite]
  42. How to automate adduser (on linux) when add new user site in multisite
  43. Activation of new Registered site fails on multisite
  44. How to force WP to create a users table in multisite configuration?
  45. Right approach in doing this signup process
  46. How to give “author” user role appropriate capabilities to add PollDaddy polls? WordPress multisite
  47. Best way to convert two single WordPress sites into Multisite network with shared user base
  48. Advice on WP site structure using multisite
  49. Trying to create site-wide Active Directory sync with Multisite
  50. How to use WordPress Multisite With Different Domain Names?
  51. How To Add Custom Form Fields To The User Profile Page?
  52. Where are available Roles Defined in the wp_ database?
  53. restore_current_blog() vs switch_to_blog()
  54. Can i merge 2 new WP_Query($variable) ‘s?
  55. How to disable a network enabled plugin for just one site?
  56. How to reliably flush rewrite rules on multisite?
  57. Site Redirecting to wp-signup.php
  58. Moving a WP Multisite to a subdirectory
  59. Cookies in multisite where network sites have their own domain name
  60. Convert a Multisite WordPress install into a Single site
  61. WordPress MultiSite Active Directory integration and site privacy
  62. WordPress Job Interview Preparation
  63. How to add Custom Blog Options to new blog setup form?
  64. How can I trust switch_to_blog()?
  65. Remove the blog slug from WordPress Multisite root node
  66. Why are my roles not visible in a Multi-site/Network?
  67. Site admin in a network install can’t edit users?
  68. How to use same email for multiple users
  69. How to run an activation function when plugin is network activated on multisite?
  70. Specific upload folder for PDFs in custom Post type in WP multisite
  71. What is the correct way to map multiple domains in a WordPress 4.1 multisite install?
  72. Where can I find documentation on what characters are allowed in user names and why?
  73. How to migrate subsite from dev multisite to production multisite
  74. How can I un-reserve a pending username registration?
  75. DB connection error after copying a WordPress Multisite instance to a second location
  76. Redirect Main Site to Subsite in Multisite WordPress
  77. Is there a is_user_logged_in() for multisite?
  78. Switching MultiSite installation from HTTP to HTTPS
  79. Allow user to select a theme to install when they signup
  80. Setting up a wordpress network with third level domains
  81. Get upload URL by blog ID in multisite
  82. What’s the difference between get_site_option and get_blog_option?
  83. Need help sorting “My Sites” Alphabetically
  84. How to delete post revisions?
  85. Create mobile site with same content just different theme
  86. Add additional Network constants to wp-config.php dynamically
  87. Multisite stuck at 1MB for max file size
  88. How to get blog name, when using WordPress Multisite
  89. What are options are there to implement a multi language site
  90. Switching primary site in WordPress Multisite
  91. Multisite Network Port Num Issues?
  92. Convert existing site to network
  93. Where is the robots.txt stored for a WordPress Multisite install?
  94. Settings API in Multisite – Missing update message
  95. Add WordPress MU Network Admin via Database
  96. How to get current site id? (WPMU)
  97. Multisite on Windows with wildcard subdomains
  98. Which asset URLs are acceptable in a “vanilla” MU install?
  99. $wpdb->base_prefix not get parent site prefix in multisite
  100. How to tell which database tables belongs to which multisite site
Categories multisite Tags multisite, multisite-user-management, wp-signup
Hide post title input for all roles except admin
Force 404 redirect to home?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress