jdrivard
Forum Replies Created
-
The init function is in /lib/config/menu.php file. Just add the line at the end for the function
public function init()
{
.
.
.\MailPoet\Segments\WP::removeOrphanedSubscribers();
}Effectively, I haven’t watch the good list.
Finally, I revolve it with an easy way.
I replaced the removeOrphanedSubscribers() with a static function, like the old one :public static function removeOrphanedSubscribers()
{//removeorphanedwpsegmentsubscribers(nothavingamatchingwpuserid),
//e.g.ifwpusersweredeleteddirectlyfromthedatabase
global $wpdb;$wp_segment = Segment::getWPSegment();
//$wp_segment->subscribers()
//->leftOuterJoin($wpdb->users,array(MP_SUBSCRIBERS_TABLE.’.wp_user_id’,’=’,’wu.id’),’wu’)
//->whereNull(‘wu.id’)
//->findResultSet()
//->set(‘wp_user_id’,null)
//->delete();//Pourfaireleménagedubug
$blogMembersID = get_users(array(‘blog_id’ => get_current_blog_id(), ‘fields’ => array(‘ID’)));
$inID = “”;
foreach ($blogMembersID as $id) {
if ($inID != “”) {
$inID .= “,”;
}
$inID .= $id->ID;
}$subscribers_table = Subscriber::$_table;
$request = sprintf(‘DELETE FROM %s WHERE wp_user_id is not null AND wp_user_id not in(‘ . $inID . ‘)’, $subscribers_table);
Subscriber::raw_execute($request);
}Then, in the init of the menu, instead of calling SynchronisezUsers, I call directly the static function :
public function init()
{
$this->checkPremiumKey();$this->wp->addAction(
‘admin_menu’,
[
$this,
‘setup’,
]
);\MailPoet\Segments\WP::removeOrphanedSubscribers();
}Hi,
We just upgrade this morning the extension. I don’t get time to reintroduce my fix, but when I access the subscribers interface, the bug seem fixed.
I see in the MailPoet changelog 3.54.3, that they fix a subscribers bug. I think, and I hope that is our bug. Have you tried to use the extension without any modification?This is the new code for the function insertSubscribers in / lib/Segments/wp.php
private static function insertSubscribers() { global$wpdb; $subscribers_table=Subscriber::$_table; $request=sprintf(' INSERT IGNORE INTO %s (wp_user_id,email,status,created_at) SELECT wu.id,wu.user_email,"subscribed",CURRENT_TIMESTAMP()FROM %s wu LEFT JOIN %s mps ON wu.id=mps.wp_user_id WHERE mps.wp_user_id IS NULL ',$subscribers_table,$wpdb->users,$subscribers_table); if(is_multisite()==true) { $blogMembersID=get_users(array('blog_id'=>get_current_blog_id(),'fields'=>array('ID'))); $inID=""; foreach($blogMembersID as $id) { if($inID!="") { $inID.=","; } $inID.=$id->ID; } $request.=' AND wu.id in('.$inID.')'; } $inserterd_user_ids = \ORM::for_table($wpdb->users)->raw_query(sprintf( 'SELECT %2$s.id, %2$s.user_email as email FROM %2$s LEFT JOIN %1$s AS mps ON mps.wp_user_id = %2$s.id WHERE mps.wp_user_id IS NULL AND %2$s.user_email != "" AND mps.id in('.$inID.')', $subscribers_table, $wpdb->users))->findArray(); Subscriber::raw_execute($request); return $inserterd_user_ids; }
Hi,
I don’t know why, but it is not resolved at this time. We bought the premium version, in hope that this feature will be corrected in this version, but it is always the same problem!
In addition to that, the function insertSubscribers has been modified. So, now, we must return an array of inserted subscribers, and I must change my code to repair your fault! It is really unacceptable!Hope you will rapidly correct the situation.
Jean-David
Hi,
You can find the wp.php in the mailpoet directory / lib/Segments/wp.php
Also, I suggest you to introduce this piece of code to repair the auto alimentation of users :
In the same file, replace the removeOrphanedSubscribers by this function :
private static function removeOrphanedSubscribers() { //removeorphanedwpsegmentsubscribers(nothavingamatchingwpuserid), //e.g.ifwpusersweredeleteddirectlyfromthedatabase global $wpdb; $wp_segment=Segment::getWPSegment(); $wp_segment->subscribers() ->leftOuterJoin($wpdb->users,array(MP_SUBSCRIBERS_TABLE.'.wp_user_id','=','wu.id'),'wu') ->whereNull('wu.id') ->findResultSet() ->set('wp_user_id',null) ->delete(); //Pour faire le menage du bug $blogMembersID=get_users(array('blog_id'=>get_current_blog_id(),'fields'=>array('ID'))); $inID=""; foreach($blogMembersID as $id) { if($inID!="") { $inID.=","; } $inID.=$id->ID; } $subscribers_table=Subscriber::$_table; $request=sprintf('DELETE FROM %s WHERE wp_user_id is not null AND wp_user_id not in('.$inID.')',$subscribers_table); Subscriber::raw_execute($request); }
Finally, to redo a correct synchronisation, call this :
\MailPoet\Segments\WP::synchronizeUsers();
Personnaly, I call this function within the contructor of the lib/Config/Menu.php.Hope will help,
Jean-David
Hi,
Do you have empty the trash?
Maybe the subscriber are also WordPress users. If yes, the MailPoet plugin will automatically synchronize wordpress users as subscribers and deleting these subscribers will result in 0 moving to trash.Jean-David
Thanks! You send me on the good track. There was a filter that blocked the anonymous wp_cron call.
Jean-David
I got exactly the same problem. Is it possible to get a hint to resolve this problem?
Thanks,
Jean-David Rivard
Hi,
I suggest this modification to the file WP.php, line 118, function insertSubscribers :
private static function insertSubscribers() { global $wpdb; $subscribers_table = Subscriber::$_table; $request = sprintf(' INSERT IGNORE INTO %s(wp_user_id, email, status, created_at) SELECT wu.id, wu.user_email, "subscribed", CURRENT_TIMESTAMP() FROM %s wu LEFT JOIN %s mps ON wu.id = mps.wp_user_id WHERE mps.wp_user_id IS NULL', $subscribers_table, $wpdb->users, $subscribers_table); if (is_multisite() == true) { $blogMembersID = get_users(array('blog_id' => get_current_blog_id(), 'fields' => array('ID'))); $inID = ""; foreach ($blogMembersID as $id) { if ($inID != "") { $inID .= ","; } $inID .= $id->ID; } $request .= ' AND wu.id in ('.$inID.')'; } Subscriber::raw_execute($request); }
With the in value that contains all members, subscribers reflect realty of the multisite environment.
Hope you will include as possible the multisite purpose in MailPoet. Without this consideration, we can’t process to buy the premium version for our organisation.
Thanks,
Jean-David Rivard
- This reply was modified 7 years, 5 months ago by jdrivard.
Is there anybody using MP3 on a multisite environment? IS the subscribers correct on your side?
Thanks,
Jean-David
Hi,
In a multisite environment, if I’m not a member of a site, I don’t have the administrator role for this site.
Jean-David
Forum: Plugins
In reply to: [MailPoet Newsletters (Previous)] Automatic newsletter mailpoet not sendingHi,
We are on WordPress 4.8 and MailPoet 2.7.10 and we got the same problem. Our classis newsletters are sending correctly, but automatic newletters isn’t send. But MailPoet do as if the newsletters was send. We can consult stats and datetime of sending. Evidently, the stats are wrong.
Is the bug fixed?