// Create the WP_User_Query object $wp_user_query = new WP_User_Query(array('role' => 'Subscriber')); // Get the results $users = $wp_user_query->get_results(); // Check for results if (!empty($users)) { // loop trough each author foreach ($users as $user) { // add points meta all the user's data add_user_meta( $user->id, 'points', '5', true ); // 5 = number of points existing users will get } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter