0

I am developing a community website. We have two separate types of members -- regular members and business members. Business members can access subscription options to sponsor the chapter (website) but the members are not able to access these subscriptions.

I am using lm_paypal for the subscriptions, as it seems to do just what we need it to do.

My only problem is that lm_paypal hardcodes their information in the user profile. THere are three blocks it places on the user profile (or rendered user): a donations block, an active subscriptions block and a block to allow you to subscribe and unsubscribe from subscriptions.

Here is the function in lm_paypal_paid_averts that does this (I think!)

/**
* Implements hook_user_view().
*/
function lm_paypal_paid_adverts_user_view($account, $view_mode) {
global $user;

// In the "my account" view area show all paid_adverts
if (user_access('administer lm_paypal') || $user->uid == $account->uid) {
$account->content['paid_adverts'] = array(
  '#type' => 'user_profile_category',
  '#title' => t('PayPal Paid Adverts'),
  '#weight' => 6, // under History which is 5.
);
$account->content['paid_adverts']['subs'] = array(
  '#type' => 'user_profile_item',
  '#title' => t('Adverts you paid with us:'),
  '#markup' => lm_paypal_paid_adverts_list_nodes($account->uid, 10),
);
 }
}

The only way I can see to display this information is by using the "Rendered User" field in Panels, which displays a lot of other things, including history, recent content, etc. It also displays it on all user profiles, regardless of whether the user can actually access the subscriptions or not (my members can click on the link, but they get access denied page). I would like to have the subscription blocks showing only on the business member profiles and the donation blocks showing on all profiles.

What I need is a way to pull out just this lm_paypal information from the rendered user so that I can display it in its own block and set access control on it so only business members can actually see the subscriptions.

I've been googling for an answer to this for almost a week and found a few different solutions that may work, but require extra modules to be installed and it seems like a lot of extra weight for just needing a piece of a whole. I've found some answers regarding placing code in places, but I have to admit, I'm so close to having this presentable, I'm slightly terrified of trying too many things and somehow messing up. I've built this site myself, starting with no experience at all, and I've had many ups and downs along the way... I am terrified being this close to done and doing something to mess it up and not be able to recover it.

So I am hopeful that someone here can give me a clear answer where I don't have to make guesses and assumptions and perhaps mess myself up!

Is there a way to pull these fields from the user profile and print them separately in their own block?

0

A lightweight custom module to create a block for your business members and one for your regular members should do it. Creating a custom block isn't as daunting as it seems, it's one of the easier customizations you can do. The Block API should be very helpful here. Here's a quick example:

 /* Implements hook_block_info() */

function myblock_block_info() {
  $blocks['my block'] = array(
    'info' => t('Business User Block'),
    'cache' => DRUPAL_CACHE_PER_PAGE
  );
  return $blocks;
}


/* Implements hook_block_save() */

function myblock_block_save($delta = '', $edit = array()) {
  variable_set('block_text_prefix', $edit['block_text_prefix']);
  variable_set('block_text_suffix', $edit['block_text_suffix']);

}

/* Implements hook_block_view() */
function myblock_block_view($delta = '') {
  //get the information you want out of the profile here
  $block['content'] = //your information formatted here
}

Devel info:

If you double click on a row in the devel table, it will tell you how to reference it: devel screenshot

  • Thank you so much for your help! I think my confusion is that I don't know how to find out what I am asking for from the userprofile, if that makes sense? I know I want this piece, but I don't know how to call for it. Is there a way to find out what the system calls it so that I can pull it from the user profile? – Heather Jul 11 '14 at 16:48
  • Absolutely! Use the Devel module - once you enable it, you'll see a tab/link on each node that will let you examine the entire structure of the node - and you can see how to reference each piece of information. – aburke626 Jul 11 '14 at 16:53
  • Oh that is incredibly helpful! Thank you. I now can see: paid_adverts (Array, 4 elements) #type (String, 21 characters ) user_profile_category #title (String, 19 characters ) PayPal Paid Adverts #weight (Integer) 6 subs (Array, 3 elements) #type (String, 17 characters ) user_profile_item #title (String, 25 characters ) Adverts you paid with us: #markup (String, 793 characters ) <table class="sticky-enabled"> <thead><tr><th ... It looks like the "subs" part is the part that is printing on the profile. What format do I use to call that out? Thank you so much -- this has been making me crazy! – Heather Jul 11 '14 at 17:36
  • I edited my answer to add a screenshot. – aburke626 Jul 11 '14 at 17:42
  • Thank you SO much! You have no idea how much you have helped me -- I have literally been trying to figure this out for days! – Heather Jul 11 '14 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.