Advertisement:

Author Topic: [SOLVED] change_email_confirm hook and location  (Read 185 times)

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
[SOLVED] change_email_confirm hook and location
« on: March 01, 2019, 10:31:47 pm »
Hello,

Anyone knows where is the location of the function for action change_email_confirm? Judging by the URL: .../index.php?page=user&action=change_email_confirm&userId=59&code=... it should be in controller/user.php but I don't see it there?
I need to save old email in session just before it's changed and then do something with both emails after they get changed.

I thought of using init hook to save email in session:

Code: [Select]
<?php
function wm_edit_user_email_pre_wordpress() {
    if(
Params::getParam('page') == 'user') {
        if(
Params::getParam('action') == 'change_email_confirm') {
            
$userid Params::getParam('id');
            
$user User::newInstance()->findByPrimaryKey($userid);
            
$email $user['s_email'];
            
Session::newInstance()->_set('email_change_old'$email);
        }
    }
}
osc_add_hook('init''wm_edit_user_email_pre_wordpress');

But now I need a hook that fires after the email gets changed.
Has anyone got ideas?

Just a quick note why I need this - I'm creating a Wordpress-Osclass bridge, so when a user changes his email address on Osclass I need to find him by his old address on Wordpress and update it. I'm using WP REST API.

Thanks, regards.
« Last Edit: March 03, 2019, 08:13:12 pm by patrickFromCroatia »

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: change_email_confirm hook and location
« Reply #1 on: March 03, 2019, 08:12:59 pm »
Don't know how I missed it, but the code for change_email_confirm is located in oc-includes/osclass/controller/user-non-secure.php, line 35.
There is also a hook: osc_run_hook('change_email_confirm', Params::getParam('userId'), $userOldEmail, $userEmailTmp['s_new_email']);.
The hook also passes old email so there is no need for init code in the upper post.

In case anyone else will be in a similar situation, Windows Grep is a great tool for searching a lot of files for a specific string.

Regards.