CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Specifying the On-behalf-of Organization by ID in the URL for a new Membership
Pages: [1]

Author Topic: Specifying the On-behalf-of Organization by ID in the URL for a new Membership  (Read 472 times)

poorhaus

  • I’m new here
  • *
  • Posts: 29
  • Karma: 0
    • Music Nova Scotia
  • CiviCRM version: 4.4.10
  • CMS version: Drupal 7
  • MySQL version: 5.5.27
  • PHP version: 5.3.17
Specifying the On-behalf-of Organization by ID in the URL for a new Membership
March 27, 2013, 11:10:41 am
Hi all,

For my use-case, individuals in the system can belong to more than one organization, any of which can have a membership which the individual inherits.  Individuals cannot hold a membership; only organizations can. The user must register, create an individual contact and then an organization contact before they can become a Member. I have this mostly sorted, I'm just trying to find a way to specify in the URL the organization on whose behalf the person is purchasing the membership.

I've attached a screenshot to illustrate the workflow; users register on the site, and create "Projects" (Organizations) which are bands, solo projects, etc. Then they add a membership for that project; here's where I'm stuck. Right now, when users click the "Add Membership" link under a given Project, they must still type in the name of the project in the autocomplete onbehalf field to attach the membership to that project. I want to have the 'Add Membership' link pass a URL parameter into the membership form to specify which Organization/Project the membership will be attached to, and have the relevant profile fields pre-filled.

I know how to do this with a renewal by passing in the membership ID (mid) and that's how my renewals work, but I cannot for the life of me figure out what parameter name/value combination to pass in to pre-select an on_behalf_of Organization for a new membership. The "My Projects" piece is a Drupal View block and I have access to the relevant tokens for both Organization Name and ID, really I just need the parameter name so I can pass it in through the URL. Is this possible?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Specifying the On-behalf-of Organization by ID in the URL for a new Membership
March 27, 2013, 04:23:46 pm

Not possible by default, but can be done via a hook.

Basically, u decide the name of the variable. Implement the hook_civicrm_buildForm in your extension (check civix) and then set the default values there. You can use a fair bit of the code from the membership renewal form

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

poorhaus

  • I’m new here
  • *
  • Posts: 29
  • Karma: 0
    • Music Nova Scotia
  • CiviCRM version: 4.4.10
  • CMS version: Drupal 7
  • MySQL version: 5.5.27
  • PHP version: 5.3.17
Re: Specifying the On-behalf-of Organization by ID in the URL for a new Membership
March 28, 2013, 08:13:47 am
OK, I've got a module constructed and I can tell from my debug code that the hook is firing correctly and that the var I'm passing through is being caught by the module, but it's still not populating the value. I figure I'm phrasing the form field name incorrectly, here's my module code:

Code: [Select]
/* test if it's the correct membership form */
if ($_GET['q'] == 'civicrm/contribute/transact' and $_GET['id'] == '2') {
echo "got the right form!"; 
if (isset ($_GET['org_name'])) {
echo "got an org name! (" . $_GET['org_name'] . ")"; 
$defaults['onbehalf[organization_name]'] = $_GET['org_name'];
$form->setDefaults($defaults);

}
else {
echo "no org name found!";

}
}
« Last Edit: March 28, 2013, 08:25:40 am by poorhaus »

poorhaus

  • I’m new here
  • *
  • Posts: 29
  • Karma: 0
    • Music Nova Scotia
  • CiviCRM version: 4.4.10
  • CMS version: Drupal 7
  • MySQL version: 5.5.27
  • PHP version: 5.3.17
Re: Specifying the On-behalf-of Organization by ID in the URL for a new Membership
March 28, 2013, 08:26:15 am
Apologies if this takes this thread into Developer territory and hence a different forum.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Specifying the On-behalf-of Organization by ID in the URL for a new Membership
March 28, 2013, 09:16:33 am

You might want to check how membership renewal sets the org id / org name etc on that form

those fields are js driven, so things are done a wee bit differently and a bit more than just setting org name.

Dont know that code well enough, to point you to the right files/line

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Specifying the On-behalf-of Organization by ID in the URL for a new Membership

This forum was archived on 2017-11-26.