Willkommen, Gast
Angemeldet bleiben:

THEMA:

Breezingforms Joomla! registration form / optional account creation 4 Jahre 7 Monate her #219487

  • Autor
  • seppi
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Beiträge: 86
  • Dank erhalten: 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

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Letzte Änderung: Post by seppi.

Breezingforms Joomla! registration form / optional account creation 4 Jahre 7 Monate her #219505

  • marinkosevos Avatar
  • marinkosevo
  • Offline
  • Benutzer ist gesperrt
  • Benutzer ist gesperrt
  • Beiträge: 747
  • Karma: 27
  • Dank erhalten: 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

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Breezingforms Joomla! registration form / optional account creation 4 Jahre 7 Monate her #219517

  • Autor
  • seppi
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Beiträge: 86
  • Dank erhalten: 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.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Breezingforms Joomla! registration form / optional account creation 4 Jahre 7 Monate her #219527

  • marinkosevos Avatar
  • marinkosevo
  • Offline
  • Benutzer ist gesperrt
  • Benutzer ist gesperrt
  • Beiträge: 747
  • Karma: 27
  • Dank erhalten: 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

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Breezingforms Joomla! registration form / optional account creation 4 Jahre 7 Monate her #219544

  • Autor
  • seppi
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Beiträge: 86
  • Dank erhalten: 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.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Breezingforms Joomla! registration form / optional account creation 4 Jahre 7 Monate her #219630

  • marinkosevos Avatar
  • marinkosevo
  • Offline
  • Benutzer ist gesperrt
  • Benutzer ist gesperrt
  • Beiträge: 747
  • Karma: 27
  • Dank erhalten: 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

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Moderatoren: ForumSupport
Ladezeit der Seite: 0.055 Sekunden

Angebot

Sommer Special! Alle Mitgliedschaften zum Sonderpreis!

Prio Support, alle Extensions und alle Templates in einem Paket.

Hier geht's zur Bestellung

Crosstec hilft sparen!

Falls Sie neu bei Crosstec sind aber bereits einen Formulargenerator bei einem anderen Hersteller gekauft haben, dann bekommen sie von uns einen Rabatt von 25% auf unsere 1-Jahres und Pro-Mitgliedschaften

Wie Sie an den Rabatt kommen?

Schreiben Sie uns einfach eine kurze Email mit beigelegten Kaufbeleg (z.B. PayPal Quittung) an sales@crosstec.org.

Wir unterstützen die Joomla Community

Crosstec unterstützt weltweit alle offiziellen Joomla! User Groups und Organisatoren von Joomla! Days die bei Joomla.org registriert sind.

Falls das auf dich zutrifft und du eines unserer Produkte brauchst, schreib uns eine kurze Email an info@crosstec.org und du bekommst eine Flatrate-Mitgliedschaft geschenkt!