Custom Fields
Support MB User Profile MB User Profile: Pass new user ID to subsequent form for post creation

  • Creator
  • #13122
    Resolved Content Pilot

    I am creating a site where the admin can create a new user, gets redirected to another page, and finally creates a custom type entry (with MB frontend submissions).

    Is it possible to pass the newly created user ID/object to the second page which is housing the MB frontend submission forms shortcode so I can assign the new post type entry author to the new user ID?

    Basically, I need the user to be assign as the author of the new post. New user, new cpt object.

Viewing 1 replies (of 1 total)
  • Author
  • #13215
    Content Pilot

    For anybody else that wants this functionality, here is what I did.

    Set the user_id as a transient in the database after the user object is created.

    add_action( 'rwmb_profile_after_save_user', 'set_user_id_as_transient', 10 ,1 ); 
    function set_user_id_as_transient( $object ) {
         set_transient( 'user_id', $object->user_id, HOUR_IN_SECONDS );

    Then modify the form submission with the transient data.

    add_filter( 'rwmb_frontend_insert_post_data', 'insert_user_id', 10, 2 );
    function insert_user_id( $data, $config ) {
        $user_id = get_transient( 'user_id' );
        if ( false !== $user_id ) {
             $data['post_author'] = $user_id;
        return $data;

    Ahn, please mark as complete.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.