Forum breadcrumbs – You are here:Asgaros Support ForumSupportauto subscribe items
Please or Register to create posts and topics.

auto subscribe items

Page 1 of 2Next

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

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.

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

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.

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?

 

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');

 

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

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');
}

 

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

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.

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);

 

Apos37 has reacted to this post.
Apos37
If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Thank you!

Quote from Asgaros on March 3, 2019, 10:42 pm

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');
}

 

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.

 

Asgaros has reacted to this post.
Asgaros
Page 1 of 2Next