WordPress.org

Ready to get started?Download WordPress

Forums

Passing value to profile_update hook (3 posts)

  1. tiszenkel
    Member
    Posted 1 year ago #

    I feel like this is going to be a simple question for someone here, but I've been struggling with it on and off for days.

    I'm adding a profile_update action to WordPress through my theme's functions.php file. I have custom radio buttons set up as part of my site's registration process through a plugin, Cimy User Extra Fields. If the user has selected one of the radio buttons, I want to perform a certain action on a profile update. When the user has selected the other, I want to perform a different action.

    This works well if the user is updating an existing profile. But I want it to work on initial registration as well, and the call to the custom radio buttons don't return anything at that point. How can I pass a value to the profile_update function in such a way that I can test for it?

  2. strangerstudios
    Member
    Posted 1 year ago #

    If you set the priority on your "do_action" higher than Cimy uses (not sure what they use, the default is 10) your code would run after theirs. So Cimy would have updated the user_meta for that user by then. Then you could lookup their values in the user meta like so...

    function my_profile_update($user_id)
    {
        //Cimy should have updated "radio" in user meta by now
        $radio = get_user_meta($user_id, "radio", true);
        //... do your checks/etc ...
    }
    do_action('profile_update', 'my_profile_update', 20); //make sure 20 is higher than Cimy uses.
  3. tiszenkel
    Member
    Posted 1 year ago #

    Wow, I completely forgot about this after eight months. I did solve the problem, and it was simple! All I did was attach the same action to the user_register hook.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.