I can get the current member like this:
$member = Member::currentUser();
How can I get a member by email address? This does NOT work:
$member = Member::GetUserByEmail('user@example.com');
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
I can get the current member like this:
$member = Member::currentUser();
How can I get a member by email address? This does NOT work:
$member = Member::GetUserByEmail('user@example.com');
What about:
$m = DataObject::get_one('Member',"Email ='".$someEmailAddress."'");
Also better make sure $someEmailAddress is SQL safe as well as SS won't do this magically for you. If $someEmailAddress is a user input (like a form) you should do $someEmailAddress = Convert::raw2sql($someEmailAddress); before the dataobject get line.
True, didn't thought of a userinput case.
Thanks. But I can't seem to use this the same way I use Member::
$member = DataObject::get_one("Member", "`Email` = 'xyz@example.com'");
$member->CustomField = 'Hello';
$member->write();
I am trying to change the value of CustomField to "Hello".
That is the correct way, write() should save it to the database. Does it not update the member table? How have you added that CustomField to the database (eg via a decorator?)