Execute a plugin function when a user profile is updated

I wrote a WordPress plugin with several functions in it. This plugin works as expected and all functions do their job. Now I need to call one of the plugin’s functions when a user updates his profile.

I tried the following piece of code within my plugin, but it didn’t work.

Read More
add_action( 'profile_update', 'myfunction');

What is the best practice to use WordPress hooks? How can I call the function from my plugin when a user profile is updated?

here the strucure of my little plugin:

<?php
/*
Plugin Name: myplugin
*/
add_action( 'admin_menu', 'myplugin' );

function myplugin() {
add_options_page( 'myplugin', 'myplugin', 'manage_options', 'myplugin_id', 'myplugin_options' );
}
function myplugin() {
if ( !current_user_can( 'manage_options' ) )  {
    wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
?>
<div class="wrap">
<?php    echo "<h2>" . 'Galette users sync' . "</h2>"; ?>

<form name="galette" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
    <input type="submit" name="Submit" value="Mise à jour" />
</form>
<?php
function function1() {
    stuff
}
function function2() {
    stuff
}
function function3() {
    stuff
}
function function4() {
    stuff
}
if($_SERVER['REQUEST_METHOD']=='POST')
{
       function4();
} 
echo '</div>';
}

?>

And I want to call function2() when a user update a profile

Any Help someone?

Related posts

Leave a Reply

1 comment