Remove Unsubscribe section from user profile if user isn't subscribed to any plan yet
hippich - October 31, 2008 - 11:43
| Project: | lm_paypal |
| Version: | 6.x-1.0 |
| Component: | LM Paypal Subscriptions |
| Category: | task |
| Priority: | normal |
| Assigned: | hippich |
| Status: | needs work |
Jump to:
Description
Hi folks!
I've noted that Unsubscribe section is shown even if user is not subscribed to any subscribe plan. I've changed a bit lm_paypal_subscription.module to resolve this issue. If it author think it needed to be incorparated into 1.x-dev version - here is patch in attach.
Cya.
| Attachment | Size |
|---|---|
| lm_paypal_subscriptions.module.patch | 1.64 KB |

#1
I think the reason there is always a link to the user's paypal is that if a subscription is deleted on the Drupal site, and there is an existing (paypal) subscription in place, the user needs a link to be able to remove this subscription.
#2
Hm. He always can do this from his paypal account anyway. Well... It's just my proposal (and what my client asked for =)). If it isnot usefull let's close this issue.
#3
I think this is useful. Would it be possible to not even have the Subscriptions info even show up anywhere for certain roles that don't use this feature? Also, I'm having trouble figuring out how to get the Subscribe link in the navigation bar for a specific role - any direction would be helpful. Thank you.
#4
The easiest way is to change into your lm_paypal directory, and then fetch the patch and apply it from there. This particular patch is not well formed (it has several windows paths at the start), so you need to :
[simon@bezol lm_paypal]$ wget -q http://drupal.org/files/issues/lm_paypal_subscriptions.module.patch[simon@bezol lm_paypal]$ patch -p3 --dry-run < lm_paypal_subscriptions.module.patch
(Stripping trailing CRs from patch.)
patching file lm_paypal_subscriptions.module
Hunk #1 succeeded at 556 (offset -19 lines).
[simon@bezol lm_paypal]$
FWIW, this part of the original code is rather unpleasant, and could really used some significant refactoring. Anyway, I would not consider the patch as it stands at the moment - the changed UI needs to be optional (configured in settings), since many people are used to the current behaviour.
#5
Thank you for the patch help.
Any suggestions on how to get the Subscribe link in the navigation bar to show up for particular roles? It shows up when I'm logged in as Admin, but not as a user. I tried to look at all the permissions, but I can't seem to get it to show up in the navigation bar. Thanks for any info.
#6
Are you talking about a link to /lm_paypal/subscribe ? Users need the "access lm_paypal_subscribe" permission to view this link. Try adding that to your user role.
Setting original issue back to CNW based on comments above.
#7
@rmassamiri
Complex solution (do not do it):
Make an access callback in which you give the user account as parameter, then alter the hook_menu so that the tab make use of this access calback.
Simple solution:
Replace the access arguments with array('some permission') in the same hook_menu item, should be enough (where 'some permission' should be a permission defined by the module's hook_perm).
Good luck.
#8
I needed to comment out to not show this in user profile. User was seeing all available subscriptions and the unsubscribe link.
* Implementation of hook_user().
*/
function lm_paypal_subscriptions_user($op, &$edit, &$account, $category = NULL) {
_lm_paypal_subscriptions_ini();
global $_lm_paypal_debug;
global $user;
// TODO: On deleting a user issue a cancel on any subscriptions
// obviously not on PayPal (can't!) just on here.
// In the "my account" view area show any role subscriptions
// but only for admin looking at other users or the user themself
// if ($op == 'view' && (user_access('administer lm_paypal') || $user->uid == $account->uid)) {
// $account->content['subscriptions'] = array(
// '#type' => 'user_profile_category',
// '#title' => t('Subscriptions'),
// '#weight' => 7, // under History which is 5 and Paid Adverts which is 6.
//);
//$account->content['subscriptions']['subs'] = array(
// '#type' => 'user_profile_item',
//'#title' => t('Current subscription status:'),
//'#value' => lm_paypal_subscribe(NULL, 32, '', NULL, $account),
//);
//}
}
#9
I vote for removing the unsubscribe link for users who do not have a subscription. Having the link is confusing to my "free" users.