I would like to run a PHP script "ONLY" when a user successfully fills out the WordPress Registration form and submits it as well as when a user updates their profile.
Here's what I have so far,
Registration
----------------
function soapConn() {
if (!isset($_POST['submit-btn'])) {
} else {
// If pressed, run the script
// Should I check for validation here? Such as if the inputs are empty?
require_once locate_template('include/xxxx.php', true);
}
}
add_action('registration_errors', 'soapConn');
Update user profile
-------------------
add_action( 'profile_update', 'my_profile_update', 10, 2 );
function my_profile_update( $user_id, $old_user_data ) {
require_once locate_template('include/xxxx.php', true);
}
By doing it this way, it could save me the trouble from listening to the registration/profile update submit button in the PHP script file.
Can someone please assist and confirm that this is the right way to approach this problem?
Thank you for your time.
exit
after the include. Have you tested this? What doesn't work?locate_template
is only going to work with theme files though.require_once( trailingslashit( get_stylesheet_directory() ) . 'include/xxx.php' );
locate_template
will work. It will not work with files in plugin directories.