• I have to pass the value of a category to code to upload an image.
    I created a custom field user_submittet_category = 9 (value to pass).
    In the code below I have ruled out the line 108 and added the 109.
    In this way, the parameter is not passed.
    If instead of get_the_ID directly insert the number of the page ID that is
    $ category = get_post_meta (get_the_ID (), ‘user_submitted_category’, true);
    the parameter is transferred and everything works perfectly.

    code:
    ……
    101 if (isset($_POST[‘user-submitted-name’])) $author = sanitize_text_field($_POST[‘user-submitted-name’]);
    102 if (isset($_POST[‘user-submitted-url’])) $url = esc_url($_POST[‘user-submitted-url’]);
    103 if (isset($_POST[‘user-submitted-email’])) $email = sanitize_email($_POST[‘user-submitted-email’]);
    104 if (isset($_POST[‘user-submitted-tags’])) $tags = sanitize_text_field($_POST[‘user-submitted-tags’]);
    105 if (isset($_POST[‘user-submitted-captcha’])) $captcha = sanitize_text_field($_POST[‘user-submitted-captcha’]);
    106 if (isset($_POST[‘user-submitted-verify’])) $verify = sanitize_text_field($_POST[‘user-submitted-verify’]);
    107 if (isset($_POST[‘user-submitted-content’])) $content = stripslashes($_POST[‘user-submitted-content’]);
    108 // if (isset($_POST[‘user-submitted-category’])) $category = intval($_POST[‘user-submitted-category’]);
    109 $category = get_post_meta(get_the_ID(), ‘user_submitted_category’, true);
    110 $result = usp_createPublicSubmission($title, $files, $ip, $author, $url, $email, $tags, $captcha, $verify, $content, $category);
    ……

    Where am I wrong? It would seem that the value of get_the_ID is null.

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

    (@viracocha50)

    I mistakenly wrote.
    I write the correct message:

    I have to pass the value of a category to code to upload an image.
    I created a custom field user_submittet_category = 9 (value to pass).
    In the code below I have ruled out the line 108 and added the 109.
    In this way, the parameter is not passed.
    If instead of get_the_ID() directly insert the number of the page ID that is
    $ category = get_post_meta (405, ‘user_submitted_category’, true);
    the parameter is transferred and everything works perfectly.

Viewing 1 replies (of 1 total)
  • The topic ‘Problems with get_the_ID’ is closed to new replies.