Hi @gutding,
is it possible to hide lists on the manage subscription page?
Yes, you can hide particular lists from the Manage Subscription page. However, this will be applied to all subscribers, not only to those not subscribed to this list yet.
To do so, you need to go to the MailPoet > Settings > Basics tab, check the “Manage Subscription page” settings and add there only the lists you’d like to be shown on this page for your subscribers.
For reference: https://kb.mailpoet.com/article/184-the-manage-subscription-page
Hi Bruna,
thanks for getting back to me. Yes, I know that I can manage which lists will be shown for all subscribers. But that does not help with my issue, where I want only already subscribed users to see a certain list.
Actually I figured that out myself by now. Just had to dig into the arrays…
If anybody else was interested, here is how I do it:
add_filter( 'mailpoet_manage_subscription_page_form_fields', 'mp_remove_manage_fields', 10);
function mp_remove_manage_fields( $form ) {
$is_unset = false;
foreach($form as $key1 => $value){
// Field cf_2 is an extra field just for customers of my special list
// so it can go if the user is not already on that list
if ($value['id']=='cf_2') {
$key_cf_2 = $key1;
// if the check for special segment was before this check
if ($is_unset) {
unset($form[$key1]);
}
}
if ($value['id']=='segments') {
$my_params = $value['params']['values'];
foreach($my_params as $key2 => $my_valP){
// my list has the id of 8
if ($my_valP['id']=8 and !$my_valP['is_checked']) {
unset($form[$key1]['params']['values'][$key2]);
// also delete the extra field for customers of this list
// see above
if (isset($key_cf_2)) {
unset($form[$key_cf_2]);
}
else {
$is_unset = true;
}
}
}
}
}
return $form;
}
Hi @gutding,
That’s nice! Thanks for sharing your workaround here so other users can benefit from it!
Sorry, there was a little error in my code. value[‘id’] looks like an integer but it is a string… So please use this:
add_filter( 'mailpoet_manage_subscription_page_form_fields', 'mp_remove_manage_fields', 10);
function mp_remove_manage_fields( $form ) {
$is_unset = false;
foreach($form as $key1 => $value){
// Field cf_2 is an extra field just for customers of my special list
// so it can go if the user is not already on that list
if ($value['id']=='cf_2') {
$key_cf_2 = $key1;
// if the check for special segment was before this check
if ($is_unset) {
unset($form[$key1]);
}
}
if ($value['id']=='segments') {
$my_params = $value['params']['values'];
foreach($my_params as $key2 => $my_valP){
// my list has the id of 8
if ($my_valP['id']=='8' and !$my_valP['is_checked']) {
unset($form[$key1]['params']['values'][$key2]);
// also delete the extra field for customers of this list
// see above
if (isset($key_cf_2)) {
unset($form[$key_cf_2]);
}
else {
$is_unset = true;
}
}
}
}
// debug_log($value,"MP_MSP_Value");
}
return $form;
}