We have "Reviewer Register page" on front-end form. There is a custom post type "Reviewers" to see reviewers lists.

When you register as a reviewer, a custom post is created with the reviewer name.

This works fine with front-end register form.

My problem is when you add "a reviewer" on back-end users page. Add a user and give him/her a role "reviewer"

But I don't know how to add a post on a custom post type (Reviewers)

My front end form add a post on a custom post type (Reviewers). but Not back-end users menu

Is there any filter for handling register or login functions on back-end or anything related login/register?

we need to add a function when you add / change a user on back-end user page.

This is how we add the user information to custom post type ("reviewer") on FRONT END.

    if($edit) $args["ID"] = $edit->ID;

    $user_id = ($edit) ? wp_update_user($args) : wp_insert_user($args);

    if(!$edit && $kko_ut=='reviewer') wp_insert_post(Array(

        "post_title"=> sprintf("%s %s", $fields['first_name'], $fields['last_name'])

        , "post_content" => ""

        , "post_status" => "publish"

        , "post_author" => $user_id

        , "post_type" => "reviewer"


We need that it works when you add users on users page on BACK END as well.

Please help.


  • This question is not clear. Please edit it to include more detail, as well as all relevant code.
    – s_ha_dum
    Commented May 29, 2014 at 3:54
  • is it better to make u understand? I don't have specific codes for it.
    – pulla
    Commented May 29, 2014 at 6:55
  • Where is that page coming from? What creates/registers the custom post type?
    – Rarst
    Commented May 29, 2014 at 8:06
  • custom post type is that "reviewers". we created the register page.
    – pulla
    Commented May 29, 2014 at 9:56
  • I added register source for insert. please have a look
    – pulla
    Commented May 29, 2014 at 10:03

1 Answer 1


Check this code

do_action('user_register', $user_id);
add_action ('user_register', "test");
function test($user_id) {
    $user = new WP_User($user_id);
    $role_of_user = $user->roles[0];
    if($role_of_user == 'your role'){
        $my_post = array(
            'post_title'    => 'My post',
            'post_content'  => 'This is my post.',
            'post_status'   => 'publish',
            'post_author'   => $user_id
        wp_insert_post( $my_post );

It will create a post when a user of your defined role is create by admin i.e from backend.

For profile update i.e if user role is update from some other role to your defined role

add_action( 'profile_update', 'my_profile_update', 10, 2 );

Use profile_update action and rest of the code same.

  • 1st of all, Thanks, so I added register code. please have a look. add_action( 'profile_update', 'my_profile_update', 10, 2 ); function my_profile_update( $user_id, $old_user_data ) { // put wp_insert code here???? }
    – pulla
    Commented May 29, 2014 at 10:03
  • oh I understand what you mean. I will try and let you know. thanks
    – pulla
    Commented May 29, 2014 at 10:07
  • I added at 1st line this.. global $user_id; (is it ok?) and works so well!! thanks
    – pulla
    Commented May 29, 2014 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.