Hi,

Thanks for the great module. Currently the "new" content-type menu for node creation is completely removed when the user does not have enough pay per node balance. Instead, we can have the "new->content-type" menu visible and on click of the it, the user can be redirected to the payment page if he does not have enough balance or node creation if he has enough balance.

Just my two cents :-)

Comments

ghosts’s picture

Has anyone found a work-around for this? I'd like the user to be directed to the payment page also if they have not purchased a node.

Thanks!

ghosts’s picture

I'm not an expert, but I did come up with this code to output a link:

<?php if (user_access('create pay-per-node products')): ?>
 <div class="button button-green">
<?php 
   global $user;
    $create = paypernode_user_can_create();
    if($user->uid == 1 || $create['job'] > 0) {
      print l('Post a Job', 'node/add/job');
    } else {
      print l('Post a Job', 'purchase/job-posting');
    }
?>
  </div>
<?php endif; ?>
phantomvish’s picture

Okay, this might not be the perfect solution but this is how I hacked the existing functions in paypernode.module to realise this...

function paypernode_node_add_new_access($type) {
    // fetching global perms
// Show all menu items that the user can create even if the ppn balance is zero
    $perms=paypernode_global_node_creation();
   
    // user can create node with or without paypernode
    if (array_key_exists($type, $perms['with_perms']))
	   return TRUE;

  $balance = paypernode_user_get_balance(NULL, $refresh);
  $cancreate = array();
  foreach ($balance as $item) {
    $cancreate[$item->node_type] = $item->allowed - $item->created;
  }
  
  if ($type) {
    return array_key_exists($type, $cancreate) ? TRUE : FALSE;
  } 
//Show all menu items that the user can create even if the ppn balance is zero
}

also...

function paypernode_global_node_creation() {
.......
  // if user can create this content sub-type using payperndode
  } 
  elseif ( array_key_exists($sub_type, $perms['with_ppn']) ) {
....
  }
  // why we get here?!?
  else {     
//drupal_not_found(); - original code
  // Redirect to payment page since the user can create this type but does not have enough ppn balance
     drupal_set_message('You have exhausted your balance for '. $type. ' entries. Kindly buy more to create a '. $type, 'error');
     drupal_goto('payment');
  //  Redirect to payment page since the user can create this type but does not have enough ppn balance
  }
phantomvish’s picture

Status: Active » Closed (fixed)