Don't activate user and don't send e-mail if userfield is checked

Started by alexanderflr, September 27, 2017, 14:57:29 PM

Previous topic - Next topic

alexanderflr

Hi,
This modification gave me a lot of headaches so I will much appreciate if someone can help me.

I want to create a shopper field (checkbox, lets name it "Don't activate me and don't send me email) that will be displayed in the registration form and
if the user check this when creates a new account, will not be activated so he will need to wait until one administrator activate him.

Thank you,
VM 3.2.8, Joomla 3.8.3, PHP 7.0.26

GJC Web Design

as your wanting to alter Joomla config settings not really a VM question

I would guess a user plugin and either onUserAfterSave($user, $isnew, $success, $msg) or onUserBeforeSave($user, $isnew, $success, $msg)
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

alexanderflr

Hi,

Thank you for your reply. I've seen this can be also done through VM shopper edit.

Basically what I would like to do is when a user register to virtuemart and check a userfield (checkbox) to be blocked or not activated.

or... what will also help me is:

if ($shoppergroup == 37113756 ) {
    block user code;

Thank you,

VM 3.2.8, Joomla 3.8.3, PHP 7.0.26

GJC Web Design

if u don't want to build a plugin you need to hack

somewhere in public function store(&$data){   in the  user.php model
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

alexanderflr

Hi,

I manage to solve this but by shoppergroup because I don't know how to get or echo values from shopper fields...
Anyway it does exactly what I needed. Here is the code:


<?php

// Get user id and shoppergroup
$user =& JFactory::getUser();
$userId $user->get('id');
$db JFactory::getDbo();
$query 'SELECT `virtuemart_shoppergroup_id` ' ' FROM `#__virtuemart_vmuser_shoppergroups` ' ' WHERE `virtuemart_user_id` =' $userId;
$db->setQuery($query);
$shoppergroup $db->loadResult(); 

// Disable user if shoppergroup =
if ($shoppergroup == 1221746709 ) {

$database =& JFactory::getDBO();
$sql "UPDATE `rk21a_users` SET `block` = '1' WHERE `rk21a_users`.`id` = $userId";
$database->setQuery($sql);
$database->query();

// Sign out the user
$app JFactory::getApplication();              
$user JFactory::getUser();
$user_id $user->get('id');            
$app->logout($user_id, array());

// Display a message for user
echo '<div class="alert alert-notice">';
 echo vmText::('not good');
 echo '</div>';
} else   

?>


VM 3.2.8, Joomla 3.8.3, PHP 7.0.26