if ( \CBLib\Application\Application::MyUser()->isGlobalModerator() ) {
CBCookie::setcookie( 'PAPVisitorId', '11111111' );
}
Please Log in to join the conversation.
/**
* PHP setcookie but smarter and more secure:
* //TBD: add domain info in cookie-name
*
* @param string $name
* @param string $value
* @param int $expire
* @param string $path
* @param string $domain
* @param boolean|null $secure Default: Null: same as session cookie
* @param boolean $httpOnly Default: true
* @return boolean
*/
public static function setcookie( $name, $value = '', $expire = 0, $path = null, $domain = null, $secure = null, $httpOnly = true )
Please Log in to join the conversation.
public function onCPayBeforeStorePaymentBasketUpdated( $paymentBasket, /** @noinspection PhpUnusedParameterInspection */ $paymentItems, /** @noinspection PhpUnusedParameterInspection */ $paymentTotalizers ) {
$integrationParams =& $paymentBasket->getParams( 'integrations' );
if ('[post_cb_codeparrainpartenaire]') {
cbimport( 'cb.session' );
CBCookie::setcookie( 'PAPVisitorId', '[post_cb_codeparrainpartenaire]' );
}
//to avoid commissions for our mods in office recording customer payments
//careful return; stops recording commissions, replace by setcookie
if ( \CBLib\Application\Application::MyUser()->isGlobalModerator() ) {
//return;
CBCookie::setcookie( 'PAPVisitorId', null, -1, null, 'activ-ha.com', null, true );
CBCookie::setcookie( 'PAPVisitorId', null, -1, null, '.activ-ha.com', null, true );
}
//fin modifs
$user = CBuser::getMyUserDataInstance();
if ( $user->get( 'cb_codeparrainpartenaire' ) ) {
$affiliateID = $user->get( 'cb_codeparrainpartenaire' );
CBCookie::setcookie( 'PAPVisitorId', '[cb_codeparrainpartenaire]' );
} else {
$affiliateID = stripslashes( cbGetParam( $_COOKIE, 'PAPVisitorId', null ) );
}
// fins
//$affiliateID = stripslashes( cbGetParam( $_COOKIE, 'PAPVisitorId', null ) );
if ( $affiliateID ) {
$integrationParams->set( 'postafpro_affiliateid', $affiliateID );
}
$paymentBasket->storeParams( 'integrations' );
}
Please Log in to join the conversation.
That just checks if the user has CB Moderator permissions. You need to ensure they actually have CB Moderator permissions as per your Moderator View Access Level within CB > Configuration > Moderation. It looks like you're just deleting the cookie though and not completely cancelling the process.Can you tell me if MyUser()->isGlobalModerator() also counts special groups (admin, super admin or managers) ?
Please Log in to join the conversation.
Another option maybe to just prevent that plugin from even loading for moderators. To do this create a view access level that includes only your customer userroups. Next edit CBSubs PostAfPro within CB > Plugin Management and change its access to your new view access level. As long as your moderators don't meet the criteria for that view access level it shouldn't even load on frontend for them and thus will not process affiliates tracking at all for them.
Please Log in to join the conversation.
if ('[post_cb_codeparrainpartenaire]') {
cbimport( 'cb.session' );
CBCookie::setcookie( 'PAPVisitorId', '[post_cb_codeparrainpartenaire]' );
}
if ( $user->get( 'cb_codeparrainpartenaire' ) ) {
$affiliateID = $user->get( 'cb_codeparrainpartenaire' );
CBCookie::setcookie( 'PAPVisitorId', '[cb_codeparrainpartenaire]' );
} else {
$affiliateID = stripslashes( cbGetParam( $_COOKIE, 'PAPVisitorId', null ) );
}
Please Log in to join the conversation.