• Resolved T0ny

    (@t0ny)


    Hi Aurovrata,

    Thanks for a great plugin.

    I have a form with post, its attributes and separate email field which is used to create a user and assign him to the post as an author.

    It’s working fine, I created the user like this, but I’m not able to assign the user to the post (the author field is empty).

    I’m using this CF option – skip_mail: on. Could you please kick me in the right direction?

    Thanks,

    Tony

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    Hi Tony,

    so just to understand your steps,

    • you have a form which new visitors can fill in to create a post (using this plugin) and you also capture their registration details (email/name).
    • when the form is submitted by a new visitor, you want to register them as a new author on your site as well as save their submission into a new post and assign this post to the newly created author

    It’s working fine, I created the user like this, but I’m not able to assign the user to the post (the author field is empty).

    your user creation function is hooked on ‘wpcf7_before_send_mail’, however this is also the hook this plugin uses to process the submission and save your post, and this may cause a conflict. You need to make sure you create your new user author after the post has been created.

    So the way I would do it is to hook the action fired at the end of the post saving process (hook #16 in the metabox helper see screenshot #8). Use this action to triger your user registration function. This action also gives you the post ID of the newly created post.

    Once you have your new user, assign the new post to this user using wp_insert_post()

    Thanks for a great plugin

    do leave a review and/or buy me a couple of beers. Thanks!

    Plugin Author Aurovrata Venet

    (@aurovrata)

    assuming you have resolved your issue and marking this thread as such

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Assign the post to a newly created user’ is closed to new replies.