Forum breadcrumbs – You are here:Asgaros Support ForumSupportEmail Notifications
Please or Register to create posts and topics.

Email Notifications

PreviousPage 2 of 2

Hi @asgaros,

I wonder if it is possible to attack it from a different angle.

Do you now if is it possible to update a forum user group automatically with the members from a wordpress user group and have this update run nightly. ie: Update forum user group A with any new members added to a corresponding Wordpress user group A so they always have the same members.

I have my WP developer looking into this as well but any insight / direction / etc you could provide would be amazing.

Cheers

Chris

Hello @studio313

For scheduled tasks you can have a look at the Wp-Cron API which allows you to run certain tasks based on a set time-period:

Cron

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

cool, ta heaps @asgaros

Hi @Asgaros,

So sorry to ask, my clients CEO has had a change of mind and he would like to reverse the functionality of having all new & existing users automatically subscribed to all forums and have it back to the default settings.

Can you please advise of the code for this.

Thank you so much in advance.

Chris

Quote from Asgaros on December 18, 2018, 10:48 am

Hello @studio313

If you want that new registered users get automatically subscribed to all new topics and posts, 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');
}
  1. add_action(‘user_register’, array($this, ‘change_subscription_settings’), 10, 1);
  2. public function change_subscription_settings($user_id) {
  3. update_user_meta($user_id, ‘asgarosforum_subscription_global_posts’, 1);
  4. delete_user_meta($user_id, ‘asgarosforum_subscription_global_topics’);
  5. }
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.

To change the subscription-settings for all existing users you can run the following PHP-script one time:

$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');
}
  1. $users = get_users();
  2. foreach ($users as $user) {
  3. update_user_meta($user>ID, ‘asgarosforum_subscription_global_posts’, 1);
  4. delete_user_meta($user>ID, ‘asgarosforum_subscription_global_topics’);
  5. }
$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');
}

 

 

Hello @studio313

You have to remove the code you added to your themes functions.php file. Additionally you have to run the following code once:

$users = get_users();

foreach ($users as $user) {
    delete_user_meta($user->ID, 'asgarosforum_subscription_global_posts');
    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!

Hi @asgaros,

Thank you very much

Have a great day

Chris

Asgaros has reacted to this post.
Asgaros
Quote from Asgaros on December 18, 2018, 10:48 amIf you want that new registered users get automatically subscribed to all new topics and posts, 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');
}

I’m getting several fatal php errors with this code. Maybe it’s incompatible with current php (7.4.27)?  In the second line, using “public” causes an error.  When I remove that, there is an error in the first line about using $this when not in object context.

So I changed the code as follows, tested with a new registration,  and that user automatically, in the Subscriptions menu, had “New Topics and Posts” chosen:

add_action('user_register', 'change_subscription_settings', 10, 1);
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');
}

I don’t understand how it works, deleting the user_meta about topics and updating about posts, but I guess working is more important than understanding 😉

Asgaros has reacted to this post.
Asgaros
PreviousPage 2 of 2