frumbert / wp2moodle-moodle

Moodle end of a Wordpress to Moodle Single Sign On auth plugin
28 stars 29 forks source link

Wordpress Marketpress and Moodle integration #4

Closed ghost closed 9 years ago

ghost commented 10 years ago

Hi Tim,

I have a WP multisite with Marketpress installed.

What would be the best way to link the Marketpress products (courses) with the courses within Moodle with the wp2moodle plugin?

You mentioned cohorts before, but does this mean a cohort should be created for each course?

I'd greatly appreciate any advice you can give me. Thanks Deon

frumbert commented 10 years ago

Yep each course typically has a cohort. I did it this way because it allowed me to sell a catalogue of courses as well, by setting both the per-course cohort as well as catalogue-cohort as membership providers per course. The link to the moodle site is via a wordpress shortcode hosted on a page / post. Not sure if Marketpress yet supports the purchase of a page (what I understand of it's digital download option is that it won't work since the url containing the pass-through data is generated on the fly since it's internally timestamped, so there's no permament link to use). Hope that helps!

ghost commented 10 years ago

Hi Tim,

Thanks for the reply. It seems I have two ways of making this happen:

  1. Create secured pages to send students to after they paid.
  2. Send the students directly to the cohort within Moodle via the "download URL". This is the better option in my opinion, but for it to work I will need the links instead of the shortlinks. Would that be possible?

Thanks for your time, it's highly appreciated. Regards, Deon

frumbert commented 10 years ago

The first option is going to be the easier I think, even though the second would be a better experience. The problem is that the link contains dynamic, time-dependant data. If you reload the page, the data changes because it's embedding a timestamp in the data that is encrypted (as well as the unique user data). So it's a different url for every instance of a user/cohort. From what I've read of MP, this kind of linking is not supported by that system.

ghost commented 10 years ago

Hi Tim,

Thanks for your reply. The staff at WPMU gave me the following reply:

"We can programmatically change the download URL using the hook I was referring to. This means we can hook that filter, and provide a new URL to use on the fly. Inside the filter we have access to order information, and of course the current logged in user.

I've never seen this particular method done before with MarketPress, but it's worth a shot to link whatever code creates the URL for the shortcode into that filter.

Otherwise I can't really say there's a best way of creating the pages per product. It would be very difficult to secure, as you don't have it tied to any order information."

The hook he's referring to, is:

MarketPress allows the download URL to be filtered:

//allows you to simply filter the url $url = apply_filters('mp_download_url', $url, $order, $download);

This means that instead of a download, we could have the "Download URL" after their purchase send them directly to the link that would be opened by the WP moodle plugin.

This would require a way to get that link via code instead of the shortcode, but might be an option.

Do you think that would be possible?

Regards, Deon

frumbert commented 9 years ago

Well, it's probably way too late, but there is now a solution for marketpress integration. The WPMU devs don't supply documentation, and were particularly unhelpful, so I did it my own way.