Suggestion for Pay To Blog

I found the sign up process for a new blog confusing when using pay-to-blog.

After signing up, the actual site is visible, and a user only sees the message and payment links when they try to login.

I feel like the payment option should happen as they signup and the site should not be there at all for a new blog when they first signup but have not paid yet.

I don’t know if this would work for everyone’s process, but it works for me.

Simply added a similar function as ‘pay_to_blog_check’ to the ‘get_header’ action hook. I tested different action hooks – init, etc. but needed to add it after the ‘template_redirect’ hook or else existing pages and 404 errors would send people to the live site (which I am trying to hide).

This way, any attempt to view the site when logged in will redirect to the payment page. Any attempt to view when not logged in, will redirect to the login page.

This is what I added:

add_action (‘get_header’, ‘pay_to_blog_site_check’,0);

function pay_to_blog_site_check() {

global $wpdb;

if ( $wpdb->blogid != 1 && !is_site_admin() ) {

if ( !strpos($_SERVER, ‘wp-admin/blog.php’:wink: ) {

$blog_expire = get_option(‘blog_expire’:wink:;

if ( empty( $blog_expire ) || $blog_expire == ‘0’ ) {

$now = time();

$now = $now – 30;

$blog_expire = $demo_period_days = get_site_option( “demo_period_days” );

$blog_expire = $blog_expire * 86400;

$blog_expire = $now + $blog_expire;

update_option(‘blog_expire’, $blog_expire);


if ( time() > $blog_expire ) {

wp_redirect( get_option(‘wpurl’:wink: .’/wp-admin/blog.php’:wink:;