Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Send subscribers to the home page after login

Users who can’t write posts (subscribers, customers) land on the home page after logging in, instead of an almost empty dashboard.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Tested with WordPress 7.1
PHP
<?php

add_filter(
	'login_redirect',
	static function ( $redirect_to, $requested, $user ) {
		// Only the default destination; a link to a specific page is kept.
		if ( $user instanceof WP_User && ! $user->has_cap( 'edit_posts' ) && ( '' === $requested || admin_url() === $requested ) ) {
			return home_url( '/' );
		}
		return $redirect_to;
	},
	10,
	3
);

In these packs

  • Admin and login: Your branding on the login page, a tidier admin, and handy extras such as duplicating posts.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.