Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
Best place to add code for managing user subscriptions?
Avatar
Natalya Murphy
Member
Free Members
sp_UserOfflineSmall Offline
Jan 27, 2013 - 10:03 am

On our system, we have a need to automatically subscribe users to certain forums when the users are activated via WP-Members.  Currently we're doing this manually through the database, but I'd like to be able to do it from the admin panel.  Which of the following would be the best way to add this code into our system?

  • Add subscription options on the user management screen in WP-Members
  • Add to the User section of the SP admin area
  • Create a whole separate SP plugin to manage subscriptions - tie in with existing subscriptions plugin code to call existing functions for adding/deleting subscriptions
  • Do something else entirely

I'm looking for the option that would be least intrusive to existing code and one that would cause the least amount of hassle when we need to install updates to existing plugins.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 27, 2013 - 11:29 am

we wouldnt do the first option... we generally try to stay away from functionality limited to single other plugin (yes, we have a couple now)...

on the second option, you didnt really offer a suggestion on the UI... how would you like to subscribe them to topics? have to know the topic id? if we had a select list of topics, that could take minutes or longer to populate on busy sites... same for list of topics and then select of users - for large user db (some of our users have over a million users in their forum) would take minutes or longer to popuplate too...

and not sure how the UI would automatically subscribe them as you state...

and actually, you can probably do that now... As long as this WP Members plugin has a simple API, like firing a hook when it creates a user, you could hook into the user creation and subscribe them automatically... assuming its using the wp api according to standards, you could just hook into the wp user creation action and subscribe them instead... something like:

add_action('user_register', 'my_member_create');
function my_member_create($userid) {
    # now add your forum subscription
    include_once(SLIBDIR.'sp-subscriptions-database.php');
    sp_subscriptions_save_forum_subscription($userid, $forumid, false);
}

just replace $forumid with the id of the forum you want to subscribe to (calculate however you need to)... that action is fired when wp creates a new user (whether through registration, admin panel or plugin using the api)... I havent actually test that but should do the trick...

using actions/filters/problem-with-post-edit-buttonooks are much more powerful than a lot of options that wont be used by most folks and allow you to customize it exactly the way you want...

Avatar
Natalya Murphy
Member
Free Members
sp_UserOfflineSmall Offline
Jan 29, 2013 - 10:19 am

Great suggestion - thanks.  I'm still pretty new to the world of plugins and still trying to wrap my brain around how all the hooks, filters, etc. all interact.  I'll take a look at the WP-Members code and see if it (hopefully) is as simple as this.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 29, 2013 - 2:21 pm

If you haven't found it already then this - http://codex.wordpress.org/Fun....._Reference - is a good place to start. SP actions and filters behave in exactly the same way built and using the same API. Ours are not all documented yet - well neither is the WP core come to that! - but we will always help identify whatever you might need.

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17363
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625