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

Member Profile Module Order of Verification Emails


Go to End


7 Posts   1369 Views

Avatar
Babalou

Community Member, 21 Posts

26 July 2015 at 12:23am

I'm using the Member Profile module, and for the most part it is working out pretty well.
It does have a peculiarity though. I want my users to verfy their emails and I want an admin to approve them but the email for approval gets sent out first. Before I waste the admin's time checking out users I want to make sure that they have at least verified their emails but the member profiles module does this the other way around: Approval first, then verification.
Looking through the code I am not seeing where the order of execution for this is defined.
Do I need to switch off the option to have an admin approve users and write something custom, or is there a known way to set the order in code or CMS?

Avatar
Babalou

Community Member, 21 Posts

29 July 2015 at 4:33am

So, in /silverstripe-memberprofiles/code/MemberProfilePage.php around line 749 there is this function : protected function addMember($form)
It has a very specific comment around line 769
// If we require admin approval, send an email to the admin and delay
// sending an email to the member.
Whereupon it does exactly that.
So how can I get around this? I'm at a bit of a loss as to how to proceed without hacking directly into this file which is of course less than optimal.
Any advice would be greatly appreciated.

Avatar
Pyromanik

Community Member, 419 Posts

30 July 2015 at 3:52am

If there's no configuration option, usually the better (less of a hack) way to do this is via an extension (ie, subclass).
Using the magic of Injector in SS3 you can (should) then be able to specify to use your subclass everywhere it uses the parent class.

This does rely on the module using ThatClass::create() though, instead of new ThatClass().

Depending on the maintenance level on the module, it may involve pull requests (in which case you could just add a config switch anyway).

Avatar
Babalou

Community Member, 21 Posts

30 July 2015 at 4:13am

Interesting.
MemberProfilePage is an extension of Page which is in turn an extension of SiteTree which means that it uses ::create() as you suggest, so now I know what I am looking for sort of.
Much obliged there Pyromanik. +1 if I could.
Will report back on results.

Avatar
Babalou

Community Member, 21 Posts

30 July 2015 at 4:18am

Well well.
I did not know that. Thanks again Pyromanik
https://docs.silverstripe.org/en/3.1/developer_guides/extending/injector/

Avatar
Babalou

Community Member, 21 Posts

30 July 2015 at 6:20am

That worked like a charm.
I created a class that extended MemberProfilePage_Controller and replaced the offending method with my own.
I just had to include an allowed action for the overridden method because it is activated through a form.
Then updated /mysite/_config/config.yml with

Injector:
  MemberProfilePage_Controller:
    class: MemberProfilePageExtension 

Flush and run.
I now can control all aspects of - well just about anything in the members profile page.
Brilliant!

Avatar
Pyromanik

Community Member, 419 Posts

30 July 2015 at 10:37pm

:)