News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

email Inactive Users

Started by Suki, April 19, 2014, 02:00:47 PM

Previous topic - Next topic

Suki

No, uninstalling the mod will not do what you want, you don't need to alter your php either, you will need to run a separate script, unfortunately, I do not have enough time to write that script for you.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

partners

Hi Suki,
Thank you for the MOD. We installed it but how do we tell if it is working?
We have a dummy account and have not logged in for a while but we never received an email.
We have SMF 2.0.7 .

Thank you again.

Suki

The mod doesn't automatically delete users, when an user has reached all the criteria for deletion that user will appear on a special list page where you can manually set them for deletion.

Do check that your test user has reached the criteria you set up.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

partners

OK, thank you.
When we look in Task Log we can not see that it is running.
Is that normal?

Thank you.

Suki

The mod doesn't add any log.

Take a look at your list of scheduled tasks, there should be a new taks named "email inactive users" or something like that, make sure its enable.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

partners

Hi Suki,
Yes it is enabled but we don't think it is sending the email.
Could we pay you to look at it if that is allowed?

Thank you.

Suki

It is pretty difficult to debug this not knowing any details at all.

Does your forum sends emails?

Do you have any users in the user list?

Whats the setting you set up for the "How many days since their last log in to receive the email" option?
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

partners

Hi Suki,
Thank you replying.
Yes our forum sends email.
We have it set not to delete users so there are no users listed but we did uncheck this box for one day and checked and there were no users listed.
We have this value "How many days since their last log in to receive the email" set to 15.

We are a little stumped but we thank you for the mod and trying to help us.

Thank you.

Suki

OK, lets figure it out of your forum does have any users that match the criteria you have.

create a new .php file inside your forum's root folder (the one where SSI.php resides) with this code:


<?php

if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');

else if(!
defined('SMF'))
die('<b>Error:</b> please verify you put this in the same place as SMF\'s index.php and SSI.php files.');

if ((
SMF == 'SSI') && !$user_info['is_admin'])
die('Admin privileges required.');

// Today is a good day to do stuff don't you think?
$today time();
$additionalgroups = array();
// Is there any custom message?
$customMessage = !empty($modSettings['eiu_message']) ? $modSettings['eiu_message'] : $txt['eiu_custom_message'];
$customSubject = !empty($modSettings['eiu_subject']) ? $modSettings['eiu_subject'] : $txt['eiu_custom_subject'];
$postLimit = !empty($modSettings['eiu_posts']) ? $modSettings['eiu_posts'] : 5;
// How many days must the user needs to be inactive to get the mail? lets stay safe here and declare a default value too.
$inactiveFor 86400 * (!empty($modSettings['eiu_inactiveFor']) ? $modSettings['eiu_inactiveFor'] : 15);
// The user hasn't been logged in since the mail was sent huh? how many days are we gonna wait until the account gets marked for deletion?
$sinceMail 86400 * (!empty($modSettings['eiu_sinceMail']) ? $modSettings['eiu_sinceMail'] : 15);
// The groups from which the users will be fetched from.
$inGroups = !empty($modSettings['eiu_groups']) ? unserialize($modSettings['eiu_groups']) : array();
// There's gotta be at least 1 group.
if (empty($inGroups) || !is_array($inGroups))
return true;
// Don't count the main admin group, AKA id_group 1
$inGroups array_diff($inGroups, array(1));
// We gotta do a nasty thing here, we have to format a "FIND_IN_SET" for each selected group. Thanks to this we need PHP 5.3
$additionalgroups array_map(
function($k) {
return ' OR FIND_IN_SET('$k .', additional_groups)';
}, $inGroups);
// For those who still want to use this but don't have php 5.3
/* foreach ($inGroups as $k)
$additionalgroups[] = ' OR FIND_IN_SET('. $k .', additional_groups)'; */

// Right, we got all we need, lets do some expensive queries.
$request $smcFunc['db_query']('''
SELECT id_member, email_address, inactive_mail, member_name, real_name, last_login
FROM {db_prefix}members
WHERE inactive_mail = 0
AND posts <= {int:postLimit}
AND last_login < {int:inactiveFor}
AND date_registered < {int:inactiveFor}
AND is_activated = 1
AND to_delete = 0
AND email_address is NOT NULL
AND (id_group IN ({array_int:groups})
OR id_post_group IN ({array_int:groups})
'
. (implode(' '$additionalgroups)). ')',
array(
'inactiveFor' => $today $inactiveFor,
'groups' => $inGroups,
'postLimit' => $postLimit,
)
);
$messages = array();
while($row $smcFunc['db_fetch_assoc']($request))
{
// Lets create the message. Replace our wildcards with the actual data.
$replacements = array(
'{user_name}' => $row['real_name'],
'{display_name}' => $row['member_name'],
'{last_login}' => timeformat($row['last_login']),
'{forum_name}' => $mbname,
'{forum_url}' => $scripturl,
);
// Split the replacements up into two arrays, for use with str_replace.
$find = array();
$replace = array();
foreach ($replacements as $f => $r)
{
$find[] = $f;
$replace[] = $r;
}
$messages[$row['id_member']] = array(
'message' => str_replace($find$replace$customMessage),
'mail' => $row['email_address'],
'subject' => str_replace($find$replace$customSubject),
);
}

if(empty($messages))
echo 'There aren\'t any users that match the criteria';

else
var_dump($messages);


Name it whatever you want, something like testemailMod.php or something  and then call it with your browser:

yoursite.com/forum/testemailMod.php

replacing "yoursite.com" with the actual name of your site

This script mimics this mod behavior without actually send and email and will list all people who match the criteria you have set up.

If you see this message:  "There aren't any users that match the criteria"  then it means you need to configure your mod settings properly since there aren't any users eligible for sending them an email.

If the script returns a list of messages to send then it means you have users matching the criteria but somehow the mod is failing to send mails.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

partners

Hi Suki,

Ok we did this and the page says "Admin privileges required."

Is this a permission problem?
Thank you for your help.


Suki

yes, its a security measure, please log in on your site as admin and run the script with the same browser you logged in as an admin
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

partners

OK, we did this and it has a huge page of users to send the message to.
In our FTP program the /public_html/Packages/eIU.zip has the owner being 99.
Could this be the problem?

Thank you.

Suki

OK, if you got a list of mesages then it means something is actually wrong with this mod, let me check further on this as I just did a quick code check and some stuff just doesn't seem right.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

partners


Suki

OK another attempt,

replace the entire file content with this:


<?php

if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');

else if(!
defined('SMF'))
die('<b>Error:</b> please verify you put this in the same place as SMF\'s index.php and SSI.php files.');

if ((
SMF == 'SSI') && !$user_info['is_admin'])
die('Admin privileges required.');

require_once(
$sourcedir '/Subs-Post.php');

$mail '';

sendmail($mail'test''this is a test message'nullnullfalse);


fill out the $mail = ''; var with the mail of your test account:

$mail = 'test@something';

and run the script with your browser again, this will directly try to send a mail to that mail account, please see if the mail was sent or received on that mail account.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

partners

OK, we did this and we received the test email.

Thank you.

Suki

thats weird then because the mod uses sendmail immediately after retrieving the users.

Are you sure you have the scheduled task created in your DB table?  can you please verify that inside table "scheduled_tasks" there is a row named "emailInactiveUsers"  and that it has the "disabled" column set to 1 ?
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

partners

Can you tell us how to do this?

Sorry.

Thank you.

Suki

if you have cpanel or similar look for "phpmyadmin" thats a tool where you can check your DB tables, pick your db, then pick the cheduled task table and you wioll be able to see its content.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

RSI

I don't know about anyone else but I've tried this mod a few times in the past couple of years or close to it and I never could get it to work. It always installed fine, but it never did do anything.

I've often wondered if it was because it only works with members who join after the mod is installed, because I had members who had not logged on in more than 3 years and I wanted it to delete their accounts, but the mod never did anything when I tried to make it work to remove those accounts in a short amount of time after I installed it. Like the other guy nothing ever appeared on the users marked for deletion list.

I installed it again early last week when this topic first appeared again and it still doesn't do anything and never sends out any emails either.

Advertisement: