Reblogging is back!

Erica's avatarWordPress.com News

As we mentioned last week, you can like and reblog posts directly from your reader, which displays a stream of all the updates published on all the blogs you follow from your WordPress.com account.

We’ve also brought the reblog button back to the toolbar that appears at the top of the screen when you’re logged into WordPress.com. Note that you’ll only see the like and reblog options while you’re looking at individual posts.

For example, you’ll see this on the left side of your toolbar while viewing https://wordpress.com/blog/read-blogs:

And your toolbar will look like this while you’re browsing the home page of en.blog.wordpress.com:

How does reblogging work?

Reblogging is a quick way to share posts published by other WordPress.com users on your own blog. People have been reblogging others’ posts since blogging started, but our new reblogging system enables authors to retain greater control over their content.

When…

View original post 312 more words

Quick hack to delete WordPress users based on their role

Someone asked for a way to delete 15000 users from WordPress based on their role.

I have this snippet I’ve used before, not sure how well it will perform for 15000, but I’m sure it can be tuned to do that 🙂

<?php
define( 'WP_USE_THEMES', false );
require_once( './wp-load.php' );
require_once( ABSPATH.'wp-admin/includes/user.php' );
$role = 'subscriber'; // The role to kill.
$reassign = 1; // The user that all posts will fall back to, other wise they will be deleted.
$this_role = sprintf( 's:%d:"%s";', strlen( $role ), $role );
$results = $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '{$wpdb->prefix}capabilities' AND meta_value LIKE %s", '%' . $wpdb->esc_like( $this_role ) . '%' ) );

if ( $results ) {
foreach ( $results as $user_id ) {
wp_delete_user( $user_id, $reassign );
}
}

(Edited to skip the wpdb->users table from the mix)

(Updated: 2017-01-06, works for WordPress 4.x, added a version which generates a PHP file with each of the delete commands)

Here is a version where you can pipe the output into a separate PHP file, review and then run.

<?php
define( 'WP_USE_THEMES', false );
require_once( './wp-load.php' );
$role = 'subscriber'; // The role to kill.
$reassign = 1; // The user that all posts will fall back to, other wise they will be deleted.
$this_role = sprintf( 's:%d:"%s";', strlen( $role ), $role );
$results = $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '{$wpdb->prefix}capabilities' AND meta_value LIKE %s", '%' . $wpdb->esc_like( $this_role ) . '%' ) );

if ( $results ) {
	echo <<<HTML
<?php
define( 'WP_USE_THEMES', false );
require_once( './wp-load.php' );
require_once( ABSPATH.'wp-admin/includes/user.php' );

HTML;
	foreach ( $results as $user_id ) {
		echo "wp_delete_user( $user_id, $reassign );\n";
	}
}

When you run it, e.g. like this:

php this-snippet.php > output.php

The output should generate something like


<?php
define( 'WP_USE_THEMES', false );
require_once( './wp-load.php' );
require_once( ABSPATH.'wp-admin/includes/user.php' );
wp_delete_user( 2, 1 );
wp_delete_user( 3, 1 );
...
wp_delete_user( 15000, 1 );

Which you can then review before you decide to delete those 15000 users.

Introducing WordAds

Team Data+Stats+Ads ftw!

Jon Burke's avatarWordPress.com News

Over the years one of the most frequent requests on WordPress.com has been to allow bloggers to earn money from their blog through ads. We’ve resisted advertising so far because most of it we had seen wasn’t terribly tasteful, and it seemed like Google’s AdSense was the state-of-the-art, which was sad. You pour a lot of time and effort into your blog and you deserve better.

Well we think we’ve cracked it, and we’re calling it WordAds.

Blogs are unique and they shouldn’t be treated like every other page on the internet. There are more than 50,000 WordPress-powered blogs coming online every day, and every time I explore them randomly I’m always surprised and delighted by how people are using the platform to express themselves.

As a WordPress user you’re breathing rarefied air on the internet: the Creators, the Independents. Creative minds aren’t satisfied being digital sharecroppers on someone…

View original post 81 more words