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?
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.
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.
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).
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.
Well well.
I did not know that. Thanks again Pyromanik
https://docs.silverstripe.org/en/3.1/developer_guides/extending/injector/
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!
:)