Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8081679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:49:01+00:00 2026-06-05T16:49:01+00:00

I am working on a 2 part form to allow users to create posts

  • 0

I am working on a 2 part form to allow users to create posts on WordPress.

The first part takes in the post title, content, and link, then creates the post from that data using AJAX. When the post is created using wp_insert_post() the post ID is returned.

function makeblog_page2form (){

    global $make_post_id;

    if( check_admin_referer('page2form_submit','page2form_subform') ){

        // more code

        $make_post_id = wp_insert_post( $post );


        exit;

    } else{
        wp_redirect( home_url( '/submission-error/' ) );
        exit;
    }

}

The second part takes an image and uploads it the WordPress gallery and then attaches the image to the post to be it’s featured image. For the image submission I am using Frontend Uploader, and using the included add_action('fu_after_upload', callback_function) with this plugin.

I am running into issues when I try to use the $make_post_id global within the add_action() to attach the image, nothing is returned.

add_action( 'fu_after_upload', function( $attachment_ids ) { 

    global $make_post_id;
    var_dump($make_post_id); // no return value

} );

Both of these are within the same file.php.

If this isn’t clear enough let me know. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:49:03+00:00Added an answer on June 5, 2026 at 4:49 pm

    Try passing this variable to the anonymous function scope:

    global $make_post_id;
    add_action( 'fu_after_upload', function( $attachment_ids ) use ($make_post_id){
        var_dump($make_post_id);
    });
    

    Global variables does not preserve values between separate request, so you have either return post ID form first call and pass it alongside uploaded files or store and access it in $_SESSION array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to dynamically create a book from code server-side. That part's working fine,
I've seen this post and it's not working (in part because it's dated). I've
I am working on a form that requires validation. A small part of the
I'm working on a really big order form with a bunch of multi-part data
Here's what I am working with: Part of my project is a windows form
I'm working on a part of a website where I generate PDFs, attach them
A part of the application I'm working on is an swf that shows a
For part of a project I'm working on I am implementing a RTPpacket where
as part of a script i am working on i have the following: loop
Part of an app I am working on includes a log file viewer, with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.