Title: Init hook function to call other hook in function.php
Last modified: August 21, 2016

---

# Init hook function to call other hook in function.php

 *  [pixel016](https://wordpress.org/support/users/pixel016/)
 * (@pixel016)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/init-hook-function-to-call-other-hook-in-functionphp/)
 * I am trying to add a function in the init hook that will call another hook like
   this but the function createNewPost is not being executed why ? :
 *     ```
       add_action( 'init', 'loadAfterUserRegistrationHook' );
           function loadAfterUserRegistrationHook(){
           add_action( 'user_meta_after_user_register', 'createNewPost' );
       }    
   
       function createNewPost( $response ){
       global $userMeta;
   
       $userID = $response->ID;
       $user = new WP_User( $userID );
   
       $role = $userMeta->getUserRole();
   
       if( $role = 'artiste' ){ 
   
           $newPost = array(
             'post_title'    => $user->nickname,
             'post_content'  => $user->description,
             'post_status'   => 'pending',
             'post_author'   => $userID,
             'post_type'     => 'cpt_artists'
           );
   
           $post_id = wp_insert_post( $newPost );
           error_log('Post ID : '.$post_id);
   
           wp_set_object_terms( $post_id, array('dj'), 'artist-category');
   
          }
        }
       ```
   

The topic ‘Init hook function to call other hook in function.php’ is closed to new
replies.

## Tags

 * [function.php](https://wordpress.org/support/topic-tag/function-php/)
 * [hook](https://wordpress.org/support/topic-tag/hook/)
 * [init](https://wordpress.org/support/topic-tag/init/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [pixel016](https://wordpress.org/support/users/pixel016/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/init-hook-function-to-call-other-hook-in-functionphp/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
