• I made a plugin that takes value from input box and calculate results.
    (Note: the plugin’s job is done during the porcess of post creating)

    I have the input box setup as post meta-box, so, I get the input value as post meta.

    When there’s an input, the plugin will do calculation.

    Now I need to save the calculated results into the post meta.
    According to this code:
    add_post_meta($post_id, $meta_key, $meta_value, $unique);
    I will need $post_id.

    The problem is– when the post is not saved yet, is there a $post_id ?
    If there is, how can I get it?

    Another question–
    In BuddyPress, we have $bp->slug->var to express values. In WordPress, how to set up some variables like this?

    Thanks in advance for your time!

    Regards

Viewing 1 replies (of 1 total)
  • Thread Starter imjscn

    (@imjscn)

    Here’s a summary of my codes:

    Class Math{
    var: $id; //I want to map this id to post_id
    var: $a;
    var: $b;
    var: $c;
    
    function calculate{
     $this->a = $value_from_post_meta_input_box;
     $this->b = $data_generated_in_calculating_process;
     $this->c = $result_of_some_function;
    }
    }

    After active the plugin, and setup the post meta input box for $a, I am able to get $a saved in post meta.
    Now, how can I save $b and $c ? How to say the current calculation is an instance of Math with current post_ID ?

Viewing 1 replies (of 1 total)
  • The topic ‘how to save to post meta without input box?’ is closed to new replies.