Hi,

Thank you so much for your tremendous module.

I would like to reward my users that share content on social networks with http://drupal.org/project/userpoints and wondering if this might be in the works one day :)

Most appreciated!

Comments

Liliplanet’s picture

Had a reply from Berdir at http://drupal.org/node/1442284

The module doesn't track clicks, it just displays them. So there is no way for a userpoints integration to know if and when a link was clicked. The only thing that you could do would be to detect clicks with javascript. And that would then be easy to game because you can just track the initial click, most services probably display some sort of form/confirmation after that. So your users could click on each icon and then use the browser back button to collect points ;)

TheCrow’s picture

i agree... need to have a trackback system or something that check the presence of the content shared, otherwise is useless... :)

SilviuChingaru’s picture

Yes but we can implement referrer.

I have the following scenario in mind:
A user click share on a page like this:
http://example.com/node/123

and I want the service link url to be:
http://example.com/referrer/[ref_code]/node/123

The referral function will redirect after referrer cookie is set to:
http://example.com/node/123

I replaced the original function of referral_get() using hook_menu_alter, with the following:

function referral_mcs_get() {
  global $user;
  
  $args = func_get_args();
  $referral = array_shift($args);
  $path = implode('/',$args);
  
  if (!$user->uid) {
    // User has not logged in, or registered yet
    $uid = _referral_ref2uid($referral);
    if (($uid) && is_numeric($uid)) {
      // Set the referral cookie
      referral_set_cookie($uid);
    }
    if(drupal_valid_path(drupal_get_normal_path($path)) ) {
      drupal_goto($path);
    }
    else {
      drupal_goto(variable_get(REFERRAL_GOTO_PATH, 'user/register'));
    }
  }
  drupal_goto();
}

Is working fine, is redirecting to any page after referrer cookie is set and if last args are valid internal or alias drupal path but I can't alter url of service links to use this functionality.

Is there a way to alter url's of service links?

Liliplanet’s picture

thank you fiftyz! looking forward to this development :)

SilviuChingaru’s picture

Temporaly I solved by appending a custom param ref=true to end of url and then modify that url using hook_outbound_alter() where the ref is set to true. But is not an elegant way...

TheCrow’s picture

hook_service_links_alter() works as all the alter functions... if you look the service_links_get_links() you may have more details about params.

SilviuChingaru’s picture

I saw the hook_service_links_alter() but we get a static 'link' key and we need to prepend to the service links url the referral link url wich is dynamic... I don't see a way to modify the service links url with dynamic content using hook_service_links_alter unless we rewrite a big part of service_links.module in our own module.

TheCrow’s picture

maybe i didnt got the point but you could add a callback function to every service and save the callback if already present in another field, then the link and settings will be elaborated by your function...

This solution is a little tricky but SL 2.x has been built over the old 1.x which was quite simple, that's why i wish rewrite the third version almost from zero starting with another perspective: #1353802: Service Links 3.x plan

Liliplanet’s picture

Issue summary: View changes

Solution using Rules Link and Autopost, see https://www.drupal.org/node/2313935