Email Notifications
Quote from studio313 on February 25, 2019, 5:55 amHi @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
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
Quote from Asgaros on February 28, 2019, 12:06 pmHello @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:
https://developer.wordpress.org/plugins/cron/
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:
Quote from studio313 on March 13, 2019, 3:43 amHi @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 amHello @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'); }
- 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’);
- }
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'); }
- $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’);
- }
$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'); }
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 amHello @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'); }
- 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’);
- }
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'); }
- $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’);
- }
$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 Asgaros on March 13, 2019, 11:40 amHello @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'); }
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'); }
Quote from Jim on January 10, 2022, 9:12 pmQuote 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 😉
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 😉