Title: Custom Action
Last modified: September 27, 2019

---

# Custom Action

 *  Resolved [aehernandez](https://wordpress.org/support/users/aehernandez/)
 * (@aehernandez)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-action/)
 * Hi!
 * I’m using your plugin to create a user via Zapier. I’m currently trying to update
   a user’s meta with a custom action that I’ve set up, but it’s not updating the
   custom meta.
 * This is the code:
 *     ```
       function custom_role_meta_fn($user_id) {
           $user_meta= get_userdata($user_id); 
           $user_roles=$user_meta->roles; 
           if (in_array('subscriber_custom', $user_roles)){
              update_user_meta( $user_id, 'simple-restrict-slug', 'yes');
           }
       } add_action('custom_role_meta', 'custom_role_meta_fn');
       ```
   
 * Could you help me with this issue?
    Thank you in advance!

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [Ironikus](https://wordpress.org/support/users/ironikus/)
 * (@ironikus)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/custom-action/#post-11976746)
 * Hey [@aehernandez](https://wordpress.org/support/users/aehernandez/) – I think
   there might be an issue with how you currently setup your custom action.
    How
   do you call the action? Do you set up the “do_action” argument and add as a value“
   custom_role_meta”?
 * If so, then you need to change the “$user_id” variable to “$user” since we parse
   the user object. We also parse the user id additionally with it as a second parameter.
   
   Simply change your code to the following and set up the do_action argument within
   Zapier.
 *     ```
        function custom_role_meta_fn($user, $user_id) {
           $user_meta= get_userdata($user_id); 
           $user_roles=$user_meta->roles; 
           if (in_array('subscriber_custom', $user_roles)){
              update_user_meta( $user_id, 'simple-restrict-slug', 'yes');
           }
       } add_action('custom_role_meta', 'custom_role_meta_fn', 10, 2);
       ```
   
 * Feel free to reach out in case you have further questions. 🙂
    -  This reply was modified 6 years, 8 months ago by [Ironikus](https://wordpress.org/support/users/ironikus/).

Viewing 1 replies (of 1 total)

The topic ‘Custom Action’ is closed to new replies.

 * ![](https://ps.w.org/wp-webhooks/assets/icon-256x256.jpg?rev=2656397)
 * [WP Webhooks - Automate repetitive tasks by creating powerful automation workflows directly within WordPress](https://wordpress.org/plugins/wp-webhooks/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-webhooks/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-webhooks/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-webhooks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-webhooks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-webhooks/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Ironikus](https://wordpress.org/support/users/ironikus/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/custom-action/#post-11976746)
 * Status: resolved