1

I am using WP Multisite to create subsites for paid users. A user will pay for a subsite on a yearly subscription basis. The subscription will renew automatically. But if the user doesn't renew, then the subsite needs to be disabled or made inactive.

I think that I will have to create a plugin that has a setting that indicates the subsite expiration date in two places:

The plugin should modify the site list (shown via the sites.php page) to show the expiration (or renewal) dates.

The plugin needs to add a field to the individual site editing screen (site-info.php) to show the expiration date

I assume that there are some filters for those two items, but need guidance as to where to start looking. (Unless there is a plugin that already has this functionality - I haven't found one yet.)

2 Answers 2

1

Since my need is two-fold, I found these answers here with a bit more searching.

  1. To add to the Edit Site page, the best option is to add another 'tab' to that page. I found an answer here: Add site options UI in Multisite Sites > Infos page , which referenced a tutorial by one of the answerers: https://rudrastyh.com/wordpress-multisite/custom-tabs-with-options.html (tutorial updated Dec 2022).

Using that tutorial as the basis, I was able to add my own tab to the Edit Site page, where I used update_option to save my own options to that site.

  1. To add a column to the Sites page, I found guidance here Add new column to sites page , which referenced code on GitHub that I used as a starting point https://gist.github.com/yratof/1e16da7e375c0a1bc278fb46e9bcf7c0

That code is as follows, which I modified for my needs:

/* Add site_name as a column */
        add_filter( 'wpmu_blogs_columns', 'add_useful_columns' );
        function add_useful_columns( $site_columns ) {
            $site_columns['site_name'] = 'Site Name';
            return $site_columns;
        }

        /* Populate site_name with blogs site_name */
        add_action( 'manage_sites_custom_column', 'column_site_name' , 10, 2 );
        function column_site_name( $column_name, $blog_id ) {
            $current_blog_details = get_blog_details( array( 'blog_id' => $blog_id ) );
            echo ucwords( $current_blog_details->blogname );
        }

With the above guidance, I was able to add my own settings tab, and then view settings in the Sites page.

0

yes you have to write code snippet or plugin that adds status field that type is boolen in wp_users table of every site that change from 0 to 1 when user have remaining expiration date and 1 to 0 when user have no expiration date. when user have no expiration date then you have to logout that user and display popup that have information about renewal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.