Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Add Fields: Member Profiles Module SS3


Go to End


11 Posts   4312 Views

Avatar
Bruce B

Community Member, 164 Posts

15 October 2014 at 4:42pm

On my machine darkan's extension.yml file does not work. Repeating the 'extensions:' line means the original one is ignored.

This should work:
---
Name: extensions
---
Member:
extensions:
- MyMemberExtension
- MemberProfileExtension

cheers
Bruce

Avatar
Anonymous user

Community Member, 1 Post

10 February 2015 at 2:26am

Hey! very later ansxer... Sorry!

---
Name: extensions
---
Member:
  extensions:
    ['MemberProfileExtension']
  extensions:
    ['MyMemberProfileExtend']

Avatar
darkan

Community Member, 4 Posts

10 February 2015 at 3:04am

Hello all, i have a new question for this modules and add fields.
I try to explain with my very bad english... sorry.
So, i use SS_3.1.8 with the MemberProfileExtend off ajshort and all is fully fonctional.

Now, i would like to add un "pre-form", before to send the normal member profil form to register.
-> add a first form with new fields,
-> call another database and return value (dont need to register in the member class),
-> save value in session::
->go to normal form of MemberProfil to register, and insert some default session value.
-> send mail to validation.

Here is what i'm do :

I know in it's don't good to insert in core (but it's only for test):

/memberprofiles/code/MemberProfilePage.php

class MemberProfilePage_Controller extends Page_Controller {
	private static $allowed_actions = array (
		//ajout formulaire_2
		'VerifFamIDForm',
		//
		'index',
		'RegisterForm',
		'afterregistration',
		'ProfileForm',
		'add',
		'AddForm',
		'confirm',
		'show',
	);
	/**
	 * My first form - Verif Fam_ID
	 */	
	public function VerifFamIDForm() {
            $fields = new FieldList(
                new TextField('fac_id', 'Num. Facture'),
				new TextField('fac_sum', 'Montant')
            );
            // Create actions
            $actions = new FieldList(
                new FormAction('doVerifFamID', 'Vérifier')
            );
			$required = new RequiredFields('fac_id', 'fac_sum');
			//
            return new Form($this, 'VerifFamIDForm', $fields, $actions, $required);
    }
	//
	public function doVerifFamID($data1, Form $form1) {
			//recup mdb
			global $databaseConfig, $databaseAutre;
			DB::connect($databaseAutre);
			//
			$sqlQuery = new SQLQuery();
			... bla bla bla
			$result1 = $sqlQuery->execute();
			//
			foreach($result1 as $row1) { 
				Session::set('fam_id', $row1['bp_family']);
				Session::set('fam_mail', $row1['per_email']);
				Session::set('fam_name', $row1['per_name']);
			}
			//
			DB::connect($databaseConfig);
			return $this->indexRegister();
	}
	//...other code...
}

memberprofiles/code/MyMemberProfileExtend.php

<?php
class MyMemberProfileExtend extends DataExtension {
	private static $db = array(
		'Identifiant' => 'Varchar(30)'
	);
	//
	public function updateMemberFormFields(FieldList $fields) {
		$fields->push(new TextField('Identifiant', 'Identifiant', Session::get('fam_id')));
		//$fields->ReplaceField('Identifiant', new TextField('Identifiant', 'Identifiant F', Session::get('fam_id')));
		$fields->ReplaceField('Email', new EmailField('Email', 'E-mail F', Session::get('fam_mail')));
		$fields->ReplaceField('Surname', new TextField('Surname', 'Nom F', Session::get('fam_name')));
		
	}
	//
	public function getCMSFields() {
		$fields = parent::getCMSFields();
	    $this->extend('updateCMSFields', $fields, $actions); 
	    return $fields; 
	}
}

/memberprofiles/templates/Layout/MemberProfilePage_register.ss

<% if session_fam_id %>
	<p>It's ok, you can register now</p>
	$Form
<% else %>
	<p>Not ok !</p>
	VerifFamIDForm
<% end_if %>

All it's ok. But when i receive the registration mail to confirm, there is no "...?key=" key value (empty).
So in the database member, the new member have an empty TempIDHash (NULL) and no ProfilePageID (0).
All other fields are good. The new field "fam_id" too. It's ok.

I'm lost in code... Please, if just you have an idea ...?!
Thanks to read.

Go to Top