TOPIC:

Breezingforms Joomla! registration form / optional account creation 3 years 8 months ago #219487

  • Topic Author
  • seppi
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 81
  • Thanks: 1
Hi

We're working with your awesome registration form. Now our customer requests to make the account creation optional, depending on the kind of membership the user chooses.

So we would need a radio button with 3 kinds of different memberships. If the user chooses membership A, the account creation must proceed in the background. If he chooses membership B or C, no account must be created.

I guess this is not a big thing, is it?

thank you

P

Please Log in or Create an account to join the conversation.

Last edit: Post by seppi.

Breezingforms Joomla! registration form / optional account creation 3 years 8 months ago #219505

  • marinkosevo's Avatar
  • marinkosevo
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 747
  • Karma: 27
  • Thanks: 92
What does he want to with the data when the user chooses no account, does he want it stored? It could be done by just putting if clause in the submit piece, that would depend on radio button selection. Do you need any help implementing this?

Best regards,
Marinko

Please Log in or Create an account to join the conversation.

Breezingforms Joomla! registration form / optional account creation 3 years 8 months ago #219517

  • Topic Author
  • seppi
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 81
  • Thanks: 1
Hi Marinko

Thanks, we appreciate you're taking care of our inquiry!

Yes, he want's to store the data in each case (if no registration is required, we don't need to store the username an password data, of course, but all other data should be stored in the db).

And yes, I would appreciate if you could give us a hint with the if selection.

our trigger field (radio group) is called

mitgliedschaft

and the options are

0;Aktivmitglied;aktivmitglied
0;Passivmitglied;passivmitglied
0;Gönnermitglied;goennermitglied
0;Forum-User;forumuser

for the cases "aktivmiglied" and "formuser" we need the registration / profile generation, for "passivmitglied" and "goennermitglied" we don't.

Does this already help for giving us a concrete hint?

In the frontend, we already managed to hide the sections containing the fields, which we need for the user account, depending on the kind of the membership.

thank you very much

P.

Please Log in or Create an account to join the conversation.

Breezingforms Joomla! registration form / optional account creation 3 years 8 months ago #219527

  • marinkosevo's Avatar
  • marinkosevo
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 747
  • Karma: 27
  • Thanks: 92
Hello,
yes this is enough. You put if statement where you check the value of 'mitgliedschaft'. Its value is stored in ff_getSubmit('mitgliedschaft'). Now you should go to begin submit piece, and set if statement
if(ff_getSubmit('mitgliedschaft') == 'aktivmitglied' || ff_getSubmit('mitgliedschaft') == 'forumuser'){
//Here should be all of the code for registration, that is already there
}

And that should be enough. Get back to me when you test it.

Best regards,
Marinko

Please Log in or Create an account to join the conversation.

Breezingforms Joomla! registration form / optional account creation 3 years 8 months ago #219544

  • Topic Author
  • seppi
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 81
  • Thanks: 1
Hi, thanks!

I just added the code in the form settings:
if(ff_getSubmit('mitgliedschaft') == 'aktivmitglied' || ff_getSubmit('mitgliedschaft') == 'forumuser'){

jimport('joomla.version');
jimport('joomla.application.component.helper'); // include libraries/application/component/helper.php
$version = new JVersion();

// Begin create user
$mainframe = JFactory::getApplication();

JFactory::getLanguage()->load('com_user');
$this->execPieceByName('ff_InitLib');

if (version_compare($version->getShortVersion(), '1.6', '<')) {
    $user = clone(JFactory::getUser());
    $pathway = & $mainframe->getPathway();
    $config = & JFactory::getConfig();
    $authorize = & JFactory::getACL();
    $document = & JFactory::getDocument();
    $usersParams = &JComponentHelper::getParams('com_users'); // load the Params
// Initialize new usertype setting
    $newUsertype = $usersParams->get('new_usertype');
    if (!$newUsertype) {
        $newUsertype = 'Registered';
    }

// Bind the post array to the user object
    $post = array(
        'name' => ff_getSubmit('name') . " " . ff_getSubmit('lastname'),
        'username' => ff_getSubmit('username'),
        'email' => ff_getSubmit('email'),
        'password' => ff_getSubmit('password'),
        'password2' => ff_getSubmit('password_pwrepeat'),
        'task' => 'register_save',
        'id' => '0',
        'gid' => '0',
    );

    if (!$user->bind($post, 'usertype')) {
        echo '<script>alert("' . addslashes($user->getError()) . '");history.go(-1);</script>';
        exit;
    } else {

// Set some initial user values
        $user->set('id', 0);
        $user->set('usertype', '');
        $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));

        $date = & JFactory::getDate();
        $user->set('registerDate', $date->toMySQL());

// If user activation is turned on, we need to set the activation information
        $useractivation = $usersParams->get('useractivation');
        if ($useractivation == '1') {
            jimport('joomla.user.helper');
            $user->set('activation', JUtility::getHash(JUserHelper::genRandomPassword()));
            $user->set('block', '1');
        }

// If there was an error with registration, set the message and display form
        if (!$user->save()) {
            echo '<script>alert("' . addslashes(JText::_($user->getError())) . '");history.go(-1);</script>';
            exit;
        } else {

            $db = & JFactory::getDBO();

            $name = $user->get('name');
            $email = $user->get('email');
            $username = $user->get('username');

            JFactory::getDBO()->setQuery("Update #__facileforms_records Set user_id = '" . $user->get('id') . "', 

username = " . JFactory::getDBO()->Quote($username) . ", user_full_name = " . JFactory::getDBO()->Quote($name) . " Where id = '" . $this->record_id . "'");
            JFactory::getDBO()->query();
        }
    }


// End create user now send mail 

    $name = $user->get('name');
    $email = $user->get('email');
    $username = $user->get('username');
    $password = ff_getSubmit('password');


    $sitename = $mainframe->getCfg('sitename');

    $mailfrom = $mainframe->getCfg('mailfrom');
    $fromname = $mainframe->getCfg('fromname');
    $siteURL = JURI::base();

    $subject = sprintf(JText::_('Account details for'), $name, $sitename);
    $subject = html_entity_decode($subject, ENT_QUOTES);

    if ($useractivation == 1) {
        $message = sprintf(JText::_('SEND_MSG_ACTIVATE'), $name, $sitename, $siteURL . "index.php?option=com_user&task=activate&activation=" . $user->get('activation'), $siteURL, $username, $password);
    } else {
        $message = sprintf(JText::_('SEND_MSG'), $name, $sitename, $siteURL);
    }

    $message = html_entity_decode($message, ENT_QUOTES);

    //get all super administrator
    $query = "SELECT name, email, sendEmail" .
            " FROM #__users" .
            " WHERE LOWER( usertype ) = 'super administrator'";
    $db->setQuery($query);
    $rows = $db->loadObjectList();

    // Send email to user
    if (!$mailfrom || !$fromname) {
        $fromname = $rows[0]->name;
        $mailfrom = $rows[0]->email;
    }

    JUtility::sendMail($mailfrom, $fromname, $email, $subject, $message);

    // Send notification to all administrators
    $subject2 = sprintf(JText::_('Account details for'), $name, $sitename);
    $subject2 = html_entity_decode($subject2, ENT_QUOTES);

    // get superadministrators id
    foreach ($rows as $row) {
        if ($row->sendEmail) {
            $message2 = sprintf(JText::_('SEND_MSG_ADMIN'), $row->name, $sitename, $name, $email, $username);
            $message2 = html_entity_decode($message2, ENT_QUOTES);
            JUtility::sendMail($mailfrom, $fromname, $row->email, $subject2, $message2);
        }
    }
} else {
//------------------1.6

    $the_name_field = ff_getSubmit('name');
    $the_email_field = ff_getSubmit('email');
    $the_password_field = ff_getSubmit('password');
    $the_username_field = ff_getSubmit('username');
    JFactory::getLanguage()->load('com_users', JPATH_SITE);

    $config = JFactory::getConfig();
    $params = JComponentHelper::getParams('com_users');

    // Initialise the table with JUser.
    $user = new JUser;
    $data = array();
    $data['activation'] = '';
    $data['block'] = 0;

    // Prepare the data for the user object.
    $data['email'] = $the_email_field;
    $data['password'] = $the_password_field;
    $data['password_clear'] = $the_password_field;
    $data['name'] = $the_name_field;
    $data['username'] = $the_username_field;
    $data['groups'] = array($params->get('new_usertype'));
    $useractivation = $params->get('useractivation');

    // Check if the user needs to activate their account.
    if (($useractivation == 1) || ($useractivation == 2)) {
        jimport('joomla.user.helper');
        $data['activation'] =JApplication::getHash(JUserHelper::genRandomPassword());
        $data['block'] = 1;
    }

    // Bind the data.
    if (!$user->bind($data)) {
        // $this->setError(JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError()));
        echo '<script>alert("' . addslashes(JText::_($user->getError())) . '");history.go(-1);</script>';
        exit;
    }

    // Load the users plugin group.
    JPluginHelper::importPlugin('user');

    // Store the data.
    if (!$user->save()) {
        // $this->setError(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError()));
        echo '<script>alert("' . addslashes(JText::_($user->getError())) . '");history.go(-1);</script>';
        exit;
    }
    
    // Compile the notification mail values.
    $data = $user->getProperties();

    $data['fromname'] = $config->get('fromname');
    $data['mailfrom'] = $config->get('mailfrom');
    $data['sitename'] = $config->get('sitename');
    $data['siteurl'] = JUri::base();

    // Handle account activation/confirmation emails.
    if ($useractivation == 2) {
        // Set the link to confirm the user email.
        $uri = JURI::getInstance();
        $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
        $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);

        $emailSubject = JText::sprintf(
                        'COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']
        );

        $emailBody = JText::sprintf(
                        'COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY', $data['name'], $data['sitename'], $data['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $data['activation'], $data['siteurl'], $data['username'], $data['password_clear']
        );
    } else if ($useractivation == 1) {
        // Set the link to activate the user account.
        $uri = JURI::getInstance();
        $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
        $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);

        $emailSubject = JText::sprintf(
                        'COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']
        );

        $emailBody = JText::sprintf(
                        'COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY', $data['name'], $data['sitename'], $data['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $data['activation'], $data['siteurl'], $data['username'], $data['password_clear']
        );
    } else {

        $emailSubject = JText::sprintf(
                        'COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']
        );

        $emailBody = JText::sprintf(
                        'COM_USERS_EMAIL_REGISTERED_BODY', $data['name'], $data['sitename'], $data['siteurl']
        );
    }

    // Send the registration email.
  $this->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody);

}

// empty passwords so they won't be stored in clear text

$pw_ = ff_getSubmit('password');
$pw_r_ = ff_getSubmit('password_pwrepeat');

$i = 0;
foreach($this->submitdata As $data){
    
    if( $data[_FF_DATA_NAME] == 'password' ){
        $this->submitdata[$i][_FF_DATA_VALUE] = '';
        $this->maildata[$i][_FF_DATA_VALUE]   = '';
        $this->savedata[$i][_FF_DATA_VALUE]   = '';
    }
    if( $data[_FF_DATA_NAME] == 'password_pwrepeat' ){
        $this->submitdata[$i][_FF_DATA_VALUE] = '';
        $this->maildata[$i][_FF_DATA_VALUE]   = '';
        $this->savedata[$i][_FF_DATA_VALUE]   = '';
    }
    $i++;

}
}

Unfortunately I get an error:

0 - Call to undefined function ff_getSubmit()

what's my mistake?

thank you.

P.

Please Log in or Create an account to join the conversation.

Breezingforms Joomla! registration form / optional account creation 3 years 8 months ago #219630

  • marinkosevo's Avatar
  • marinkosevo
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 747
  • Karma: 27
  • Thanks: 92
You have to make the following call to setup the built-in functions:
$this->execPieceByName('ff_InitLib');
Place it on top.

Best regards,
Marinko

Please Log in or Create an account to join the conversation.

Moderators: ForumSupport
Time to create page: 0.052 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!