auto subscribe items
Quote from sander1 on October 29, 2018, 10:25 amHi,
i have this small intranet (with very little amount of items), for which i want that users get automatically subsribed to everything.
Can i do this?
Regards,
Sander
Hi,
i have this small intranet (with very little amount of items), for which i want that users get automatically subsribed to everything.
Can i do this?
Regards,
Sander
Quote from Asgaros on October 30, 2018, 6:36 amHello @sander1
Currently the subscription-functionality is opt-in only to fulfill legal rules of certain countries regarding unwanted messages.
If you want that new registered users get automatically subscribed to everything, you have to add the following code to your themes functions.php file:
add_action('user_register', array($this, 'change_subscription_settings'), 10, 1); public function change_subscription_settings($user_id) { update_user_meta($user_id, 'asgarosforum_subscription_global_posts', 1); delete_user_meta($user_id, 'asgarosforum_subscription_global_topics'); }Existing users must visit the subscriptions-area in the frontend and enable the “New Topics & Posts” option there.
Hello @sander1
Currently the subscription-functionality is opt-in only to fulfill legal rules of certain countries regarding unwanted messages.
If you want that new registered users get automatically subscribed to everything, you have to add the following code to your themes functions.php file:
add_action('user_register', array($this, 'change_subscription_settings'), 10, 1); public function change_subscription_settings($user_id) { update_user_meta($user_id, 'asgarosforum_subscription_global_posts', 1); delete_user_meta($user_id, 'asgarosforum_subscription_global_topics'); }
Existing users must visit the subscriptions-area in the frontend and enable the “New Topics & Posts” option there.
Quote from ve3meo on March 3, 2019, 9:59 pmIs there a setting stored somewhere in the WP database that the admin can change so that all WP subscribers are forum subscribers? I’ve just started a forum on an established WP site.
Is there a setting stored somewhere in the WP database that the admin can change so that all WP subscribers are forum subscribers? I’ve just started a forum on an established WP site.
Quote from ve3meo on March 3, 2019, 10:10 pmI found it. The table wp_user_meta needs to be appended with one record per user per forum.
umeta_id = null user_id = user_id from wp_users meta_key = 'asgarosforum_subscription_forum' meta_value = 1 (my one and only forum)Is that sufficient?
I found it. The table wp_user_meta needs to be appended with one record per user per forum.
umeta_id = null user_id = user_id from wp_users meta_key = 'asgarosforum_subscription_forum' meta_value = 1 (my one and only forum)
Is that sufficient?
Quote from Asgaros on March 3, 2019, 10:38 pmHello @ve3meo
Currently there is no option for this available because of legal reasons. In a couple of countries – especially in Europe – there are strict privacy rules which dont allow you as a site-owner to send mails to users without their agreement. Thats why all subscription options are opt-in only.
If you really want to change this behavior then its on your own risk. In this case the asgarosforum_subscriber_mails_new_topic filter is the way to go. With this filter you can modify the array containing the mails of users who should get notified about a new topic right before the mails are sent.
Here is an example code which you can add to your themes functions.php file:
function notify_about_new_topic_mails($mails) { $users = get_users(); foreach ($users as $user) { if (!in_array($user->user_email, $mails)) { $mails[] = $user->user_email; } } return $mails; } add_filter('asgarosforum_subscriber_mails_new_topic', 'notify_about_new_topic_mails');
Hello @ve3meo
Currently there is no option for this available because of legal reasons. In a couple of countries – especially in Europe – there are strict privacy rules which dont allow you as a site-owner to send mails to users without their agreement. Thats why all subscription options are opt-in only.
If you really want to change this behavior then its on your own risk. In this case the asgarosforum_subscriber_mails_new_topic filter is the way to go. With this filter you can modify the array containing the mails of users who should get notified about a new topic right before the mails are sent.
Here is an example code which you can add to your themes functions.php file:
function notify_about_new_topic_mails($mails) { $users = get_users(); foreach ($users as $user) { if (!in_array($user->user_email, $mails)) { $mails[] = $user->user_email; } } return $mails; } add_filter('asgarosforum_subscriber_mails_new_topic', 'notify_about_new_topic_mails');
Quote from Asgaros on March 3, 2019, 10:42 pmAs an alternative you can also execute the following script once if your users should all get subscribed to all new topics:
$users = get_users(); foreach ($users as $user) { delete_user_meta($user->ID, 'asgarosforum_subscription_global_posts'); update_user_meta($user->ID, 'asgarosforum_subscription_global_topics', 1); }Or you can also execute the following script once if your users should all get subscribed to everything:
$users = get_users(); foreach ($users as $user) { update_user_meta($user->ID, 'asgarosforum_subscription_global_posts', 1); delete_user_meta($user->ID, 'asgarosforum_subscription_global_topics'); }
As an alternative you can also execute the following script once if your users should all get subscribed to all new topics:
$users = get_users(); foreach ($users as $user) { delete_user_meta($user->ID, 'asgarosforum_subscription_global_posts'); update_user_meta($user->ID, 'asgarosforum_subscription_global_topics', 1); }
Or you can also execute the following script once if your users should all get subscribed to everything:
$users = get_users(); foreach ($users as $user) { update_user_meta($user->ID, 'asgarosforum_subscription_global_posts', 1); delete_user_meta($user->ID, 'asgarosforum_subscription_global_topics'); }
Quote from Apos37 on October 4, 2019, 12:31 amIs there a way to subscribe users with a specific role to a specific category or topics? We are using this privately for our company, and we want to subscribe different employees to different topics since monitoring these will be part of our company policy. No need to worry about privacy legalities here. Thanks.
Is there a way to subscribe users with a specific role to a specific category or topics? We are using this privately for our company, and we want to subscribe different employees to different topics since monitoring these will be part of our company policy. No need to worry about privacy legalities here. Thanks.
Quote from Asgaros on October 10, 2019, 7:37 pmHello @gogrw
Possible, but difficult. Basically you have to hook into the action which is getting executed when an users get added/removed to/from a group:
- asgarosforum_usergroup_123_add_user
- asgarosforum_usergroup_123_remove_user
The 123 must be replaced with the ID of the corresponding usergroup-ID. Those hooks have the following arguments:
- User-ID
- Usergroup-ID
For this action you can use this information to subscribe those users to a certain topic/forum:
add_user_meta($USERID, 'asgarosforum_subscription_topic', $TOPICID); add_user_meta($USERID, 'asgarosforum_subscription_forum', $FORUMID);
Hello @gogrw
Possible, but difficult. Basically you have to hook into the action which is getting executed when an users get added/removed to/from a group:
- asgarosforum_usergroup_123_add_user
- asgarosforum_usergroup_123_remove_user
The 123 must be replaced with the ID of the corresponding usergroup-ID. Those hooks have the following arguments:
- User-ID
- Usergroup-ID
For this action you can use this information to subscribe those users to a certain topic/forum:
add_user_meta($USERID, 'asgarosforum_subscription_topic', $TOPICID); add_user_meta($USERID, 'asgarosforum_subscription_forum', $FORUMID);
Quote from Jim on January 12, 2022, 4:55 pmQuote from Asgaros on March 3, 2019, 10:42 pmAs an alternative you can also execute the following script once if your users should all get subscribed to all new topics:
$users = get_users(); foreach ($users as $user) { delete_user_meta($user_id, 'asgarosforum_subscription_global_posts'); update_user_meta($user_id, 'asgarosforum_subscription_global_topics', 1); }Or you can also execute the following script once if your users should all get subscribed to everything:
$users = get_users(); foreach ($users as $user) { update_user_meta($user_id, 'asgarosforum_subscription_global_posts', 1); delete_user_meta($user_id, 'asgarosforum_subscription_global_topics'); }
I think (but could be wrong) that this code is incorrect, at least as things are now. In my case I had to change
$user_id
to$user->ID
.
Quote from Asgaros on March 3, 2019, 10:42 pmAs an alternative you can also execute the following script once if your users should all get subscribed to all new topics:
$users = get_users(); foreach ($users as $user) { delete_user_meta($user_id, 'asgarosforum_subscription_global_posts'); update_user_meta($user_id, 'asgarosforum_subscription_global_topics', 1); }Or you can also execute the following script once if your users should all get subscribed to everything:
$users = get_users(); foreach ($users as $user) { update_user_meta($user_id, 'asgarosforum_subscription_global_posts', 1); delete_user_meta($user_id, 'asgarosforum_subscription_global_topics'); }
I think (but could be wrong) that this code is incorrect, at least as things are now. In my case I had to change $user_id
to $user->ID
.