The MU forums have moved to WordPress.org

SOLVED: introduce features for paying customers only (46 posts)

  1. Ovidiu
    Member
    Posted 17 years ago #

    hi there.

    some of you have big blogging comunities around and I remember seing some who offer extra functionality or extra plugins as a payed option.

    how did you go about to do that? that would basically fullfill my need to give access to certain plugins only to certain people...

  2. andrea_r
    Moderator
    Posted 17 years ago #

    I think (not sure) they used the plugin manager as a base, which enables plugins on a user-by-user basis.

  3. Ovidiu
    Member
    Posted 17 years ago #

    the mu plugin manager is not that powerfull, all it does is enable/disable globally plugins, users can still reenable them...

  4. quenting
    Member
    Posted 17 years ago #

    I'm working on something like this, hopefully for the end of the year. I'd like it subscription-based, which makes things a bit more difficult, but the gist of it is to maintain the subscription status in a separate table, have a subscriber option and add "if" when needed on a specific feature.

    Out of curiosity, what do you think about having the users pay for ?

    I plan on:
    - domain name
    - more storage
    - no ads /use your own ads
    - maybe email

    I'd be interested in other ideas of valuable things to make available to "premium" accounts.

  5. drmike
    Member
    Posted 17 years ago #

    I haven't worked this through in writing yet but the idea I had was to introduce a new record with the individual blog's options table with a 'yes' or 'no' flag on if a feature is available for that blog. It looks like looking at the Dashboard -> Site Admin -> Blogs -> Edit Blog page that the coding just displays each and every record within that option table.

    Would just be a matter of adding in the record into the upgrade-schema.php file I would think and then running an upgrade.

    I may be wrong though. :)

  6. parakeet
    Member
    Posted 17 years ago #

    I'd be really keen on seeing/using one of these eventual solutions.

  7. andrea_r
    Moderator
    Posted 17 years ago #

    More options:

    - control over themes
    - more plugins
    - PM between users (which I don;t think has even been mentioned yet)
    - friend's pages

  8. wpvince
    Member
    Posted 17 years ago #

    So does the upgrade-schema.php already exist, and prepared by the devs here to implement chargeable extras in the future?

    Others interested in this here:
    http://mu.wordpress.org/forums/topic.php?id=989&replies=7

  9. andrea_r
    Moderator
    Posted 17 years ago #

  10. wpvince
    Member
    Posted 17 years ago #

    Sorry andrea, but I'm not a coder.
    Does your response imply WPMU is ready for chargeable extras?
    Thanks

  11. andrea_r
    Moderator
    Posted 17 years ago #

    If you're a coder... yeah.

  12. PerS
    Member
    Posted 17 years ago #

    andrea_r, where's that ? Somehow I don't see it (must be my glasses :)

  13. djsteve
    Member
    Posted 17 years ago #

    OH YEAH! If this can happen, especially the:
    "PM between users (which I don;t think has even been mentioned yet)"

    I would be very very happy, I'll donate a $50 gift card to anyone who can make a functioning version of the paid user level upgrades that include the above ideas. Of course we would like to control which of these features to include or not with a toggle or something.. integrate in to the blog by blog, or user by user, or global enable features... very cool ideas here.

  14. eminemjamesuk
    Member
    Posted 17 years ago #

    Uhh...PMing between users has long been done. Check http://www.journalblue.com

  15. mypatricks
    Member
    Posted 17 years ago #

    djsteve, how do you think about paid feature on blogates.com? :)

  16. wpvince
    Member
    Posted 17 years ago #

    I want to add that I also would pay towards these features, and probably many others here would too.

    What are the chances of this happening?

    Something similar to what they have implemented on bloghoster.net would be cool.

  17. eminemjamesuk
    Member
    Posted 17 years ago #

    Pay for free software? LOL.

  18. Ovidiu
    Member
    Posted 17 years ago #

    @ eminemjamesuk

    very funny, indeed. we ask for a friends plugin and you point us to your wpmu install, where indeed you have installed it, but we want to use this plugin on our blogs too, so maybe you could answer the question where we can get that plugin? I already asked this here: http://mu.wordpress.org/forums/topic.php?id=3106&replies=15#post-18841
    and here: http://mu.wordpress.org/forums/topic.php?id=3081&replies=6#post-18529
    and here: http://mu.wordpress.org/forums/topic.php?id=3081&replies=6#post-18529

    maybe you care to share your plugin?

  19. Ovidiu
    Member
    Posted 17 years ago #

    nevermind I guess you are using this plugin: http://wpmudevorg.wordpress.com/project/WPMU-Friend-List

    I don't know how I and so many others have missed this plugin as its been there for quite a while...

  20. eminemjamesuk
    Member
    Posted 17 years ago #

    Umm...yeah, well truth is I have no idea which plugins we're using. I'm not the guy in charge of coding.

  21. wpvince
    Member
    Posted 17 years ago #

    "eminemjamesuk
    Pay for free software? LOL."

    Not quite. User would be paying for premium hosting services, and your time to maintain everything, not the software.

    Suprised you've never heard of this business model before now.

  22. drmike
    Member
    Posted 17 years ago #

    Pay for free software? LOL.

    It's free as to what you can do with it. It's not free as in money.

    Gotta admit though it;s one of the reasons why I really don't code much anymore.

  23. quenting
    Member
    Posted 17 years ago #

    I've introduced premium accounts myself in early january. The key benefits are more storage space, and the ability to remove ads / place your own ads instead, for 5 euros per month.

    It's not paying for free software. It's paying for hosting, support, maintenance, and not having to bloody care about the software.

  24. sycophant
    Member
    Posted 17 years ago #

    I've started writing a function for managing premium blogs myself.

    My initial intentions are:
    - Remove (or replace) ads.
    - Allow personal domain names.
    - More storage space.
    - More plugins.

    I intend to do this as a self-contained plugin with no hacks (beyond maybe some theme additions) required. But I haven't got too far yet (I've only put a couple of hours in so far).

    However my time for development of this is pretty limited at the moment, so it'll be a bit slow - in the mean time I'll keep my eyes open here for the other efforts.

  25. drmike
    Member
    Posted 17 years ago #

    Would you believe that this is another simple one? Those walks home may be time consuming but I can work through things.

    Easiest method to do this is add in additional options to each blog and set up some flags.

    Let's say you created a CSS editor and you want to only allow certain folks use it. The first thing you need to do is set up a option record within the blog to make this a option for the blog:

    - Open up wp-admin/upgrade-schema.php for editing.
    - Go down until you hit the function populate_options.
    - See all those add_option lines? What we need to do is add in our own with a default. For example, we'll add in the following line:
    add_option('edit_css', 0);

    This way when a new blog is created, it will already have the flag set in there to be negative.

    But what to do with blogs already created? We're going to have to fake an upgrade.

    - Open up wp-includes/version.php for editing.
    - See that line that lists the current database version number? Add '1' to it. For example if it's currently 3845, edit it to show as 3846. Be sure to save the file afterwards. (The software checks against the version numbers. If they match, it assumes it's already been done.)
    - Open up wp-admin/upgrade-functions.php for editing and go about a third of the way down. You should see a bit like the following:

    if ( $wp_current_db_version < 3308 )
    upgrade_160();

    What we need to do is add our own in there. Since in this case we're just adding in a single add_option we're just take care of it right there and not worry about any other functions.

    if ( $wp_current_db_version < 4000 )
    add_option( "edit_css", 0 );

    Save it afterwards.
    - Run the upgrade from the Site Admin menu.

    All your blogs should now have this flag set as default.

    How to activate this flag? When you get a user who has paid their ten bucks or whatever, just go into Dashboard -> Site Admin -> Blogs -> Find their blog and edit it. Using thte example above, your should now have a field with 'Edit Css' in front of it. Change it to 1 and save.

    How to use the flag? In case of a plugin, it's just a matter of wrapping the add_menu lines within a get_option check. For example:

    if (get_option("edit_css")) {
    add_options_page('Anarchy Options', 'Anarchy', 'manage_options', basename(dirname(__FILE__)) .'/anarchy-options.php', 'anarchy_options_page');
    }

    Hope this helps,
    -drmike

  26. eminemjamesuk
    Member
    Posted 17 years ago #

    Would they be editing the site-wide CSS or just their site's CSS?

  27. frozonecold
    Member
    Posted 17 years ago #

    I would hope that it is their own CSS.

  28. drmike
    Member
    Posted 17 years ago #

    It would be for detecting a plugin that they may or may not have access to. I just used the CSS editor as an example.

    Has nothing to do with actually editing their CSS I'm afraid.

  29. topherrosado
    Member
    Posted 17 years ago #

    I created a flag called "is_premium" using these instructions, and I was able to create a "Premium Plugins" page using wp-admin/plugins.php as the base and by defining PREMIUMPLUGINDIR in wp-settings.php. This is what I did:

    
    <?php
    require_once('admin.php');
    
    function get_premium_plugins() {
    	global $wp_premium_plugins;
    
    	if ( isset( $wp_premium_plugins ) ) {
    		return $wp_premium_plugins;
    	}
    
    	$wp_premium_plugins = array ();
    	$premium_plugin_root = ABSPATH . PREMIUMPLUGINDIR;
    
    	// Files in wp-content/plugins directory
    	$premium_plugins_dir = @ dir( $premium_plugin_root);
    	if ( $premium_plugins_dir ) {
    		while (($file = $premium_plugins_dir->read() ) !== false ) {
    			if ( preg_match( '|^.+$|', $file ))
    				continue;
    			if ( is_dir( $premium_plugin_root.'/'.$file ) ) {
    				$premium_plugins_subdir = @ dir( $premium_plugin_root.'/'.$file );
    				if ( $premium_plugins_subdir ) {
    					while (($subfile = $premium_plugins_subdir->read() ) !== false ) {
    						if ( preg_match( '|^.+$|', $subfile ))
    							continue;
    						if ( preg_match( '|.php$|', $subfile ))
    							$premium_plugin_files[] = "$file/$subfile";
    					}
    				}
    			} else {
    				if ( preg_match( '|.php$|', $file ))
    					$premium_plugin_files[] = $file;
    			}
    		}
    	}
    
    	if ( !$premium_plugins_dir || !$premium_plugin_files )
    		return $wp_premium_plugins;
    
    	foreach ( $premium_plugin_files as $premium_plugin_file ) {
    		if ( !is_readable( "$premium_plugin_root/$premium_plugin_file" ) )
    			continue;
    
    		$premium_plugin_data = get_plugin_data( "$premium_plugin_root/$premium_plugin_file" );
    
    		if ( empty ( $premium_plugin_data['Name'] ) )
    			continue;
    
    		$wp_premium_plugins[premium_plugin_basename( $premium_plugin_file )] = $premium_plugin_data;
    	}
    
    	uasort( $wp_premium_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));
    
    	return $wp_premium_plugins;
    }
    
    $menu_perms = get_site_option( "menu_items" );
    if( is_array( $menu_perms ) == false )
    	$menu_perms = array();
    
    if( $menu_perms[ 'plugins' ] != 1 )
    	return;
    
    if ( isset($_GET['action']) ) {
    	if ('activate' == $_GET['action']) {
    		check_admin_referer('activate-plugin_' . $_GET['plugin']);
    		$current = get_option('active_plugins');
    		$plugin = trim($_GET['plugin']);
    		if ( validate_file($plugin) )
    			wp_die(__('Invalid plugin.'));
    		if ( ! file_exists(ABSPATH . PREMIUMPLUGINDIR . '/' . $plugin) )
    			wp_die(__('Plugin file does not exist.'));
    		if (!in_array($plugin, $current)) {
    			$current[] = $plugin;
    			sort($current);
    			update_option('active_plugins', $current);
    			include(ABSPATH . PREMIUMPLUGINDIR . '/' . $plugin);
    			do_action('activate_' . $plugin);
    		}
    		wp_redirect('premium-plugins.php?activate=true');
    	} else if ('deactivate' == $_GET['action']) {
    		check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
    		$current = get_option('active_plugins');
    		array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
    		update_option('active_plugins', $current);
    		do_action('deactivate_' . trim( $_GET['plugin'] ));
    		wp_redirect('premium-plugins.php?deactivate=true');
    	}
    	exit;
    }
    
    $title = __('Manage Extras');
    require_once('admin-header.php');
    
    // Clean up options
    // If any plugins don't exist, axe 'em
    
    $check_plugins = get_option('active_plugins');
    
    // Sanity check.  If the active plugin list is not an array, make it an
    // empty array.
    if ( !is_array($check_plugins) ) {
    	$check_plugins = array();
    	update_option('active_plugins', $check_plugins);
    }
    
    // If a plugin file does not exist, remove it from the list of active
    // plugins.
    foreach ($check_plugins as $check_plugin) {
    	if (!file_exists(ABSPATH . PREMIUMPLUGINDIR . '/' . $check_plugin)) {
    			$current = get_option('active_plugins');
    			$key = array_search($check_plugin, $current);
    			if ( false !== $key && NULL !== $key ) {
    				unset($current[$key]);
    				update_option('active_plugins', $current);
    			}
    	}
    }
    ?>
    
    <?php if (isset($_GET['activate'])) : ?>
    <div id="message" class="updated fade"><p><?php _e('Extra <strong>activated</strong>.') ?></p>
    </div>
    <?php endif; ?>
    <?php if (isset($_GET['deactivate'])) : ?>
    <div id="message" class="updated fade"><p><?php _e('Extra <strong>deactivated</strong>.') ?></p>
    </div>
    <?php endif; ?>
    
    <div class="wrap">
    <h2><?php _e('Extras Management'); ?></h2>
    <p><?php _e('Extras extend and expand the functionality of your blog. You may activate or deactivate them here.'); ?></p>
    <?php
    
    if ( get_option('active_plugins') )
    	$current_plugins = get_option('active_plugins');
    
    $plugins = get_premium_plugins();
    
    if (empty($plugins)) {
    	echo '<p>';
    	_e("Couldn’t open plugins directory or there are no plugins available."); // TODO: make more helpful
    	echo '</p>';
    } else {
    ?>
    <table class="widefat plugins">
    	<thead>
    	<tr>
    		<th><?php _e('Extras'); ?></th>
    		<th style="text-align: center"><?php _e('Version'); ?></th>
    		<th><?php _e('Description'); ?></th>
    		<th style="text-align: center"<?php if ( current_user_can('edit_plugins') ) echo ' colspan="2"'; ?>><?php _e('Action'); ?></th>
    	</tr>
    	</thead>
    <?php
    	$style = '';
    
    	foreach($plugins as $plugin_file => $plugin_data) {
    		//if (!premiumBlogs::allowedPlugin($plugin_file)) continue;
    		$style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
    
    		if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
    			$toggle = "<a href='" . wp_nonce_url("premium-plugins.php?action=deactivate&amp;plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
    			$plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>";
    			$style .= $style == 'alternate' ? ' active' : 'active';
    		} else {
    			$toggle = "<a href='" . wp_nonce_url("premium-plugins.php?action=activate&amp;plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
    		}
    
    		$plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
    
    		// Sanitize all displayed data
    		$plugin_data['Title']       = wp_kses($plugin_data['Title'], $plugins_allowedtags);
    		$plugin_data['Version']     = wp_kses($plugin_data['Version'], $plugins_allowedtags);
    		$plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags);
    		$plugin_data['Author']      = wp_kses($plugin_data['Author'], $plugins_allowedtags);
    
    		if ( $style != '' )
    			$style = 'class="' . $style . '"';
    		if ( is_writable(ABSPATH . 'wp-content/premium-plugins/' . $plugin_file) )
    			$edit = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>";
    		else
    			$edit = '';
    
    		echo "
    	<tr $style>
    		<td class='name'>{$plugin_data['Title']}</td>
    		<td class='vers'>{$plugin_data['Version']}</td>
    		<td class='desc'><p>{$plugin_data['Description']} </p></td>
    		<td class='togl'>$toggle</td>";
    		/*if ( current_user_can('edit_plugins') )
    		echo "
    		<td>$edit</td>";*/
    		echo"
    	</tr>";
    	}
    ?>
    
    </table>
    <?php
    }
    ?>
    
    </div>
    
    <?php
    include('admin-footer.php');
    ?>

    It almost works. I can drop a plugin into premium-plugins/ and it'll appear, and I can click the activate link. When i do that, it appears to work, but the plugin does not get activated.

    I was using the Simple Forum plugin as my test, and I did change all hard-coded references to wp-content/plugins/ in it to wp-content/premium-plugins/ to ensure that there would be no problems with it. However, after activating it through the Premium Plugin interface, it turned out not to be activated.

    Which function actually activates plugins in the database? I think that's the only thing I'm missing in getting this to work.

  30. lunabyte
    Member
    Posted 17 years ago #

    Have you tried another plugin, to see if it was the plugin or not?

About this Topic