PHP multiple forms, same page, isset($_POST[]) not working?

Few problems I see here.

1.) You’re using concatenation for $results (ie $results .= should be $results =)

2.) You’re assuming that $webinar_code will always be available. If the page they are redirected to is not the same exact page, that will not be the case, or if the page redirected to has the shortcode but different webinar in attributes, will update the wrong one.

I would instead do it like this:

add_shortcode( 'enroll_form_button', 'enroll_form_button_function' );

function enroll_form_button_function( $atts ) {

    $atts         = shortcode_atts( array( 'redirect' => '#', 'webinar' => '', ), $atts );
    $redirect_to  = $atts['redirect'];
    $webinar_code = $atts['webinar'];

    $results = "<form id=\"form-{$webinar_code}\" method=\"post\" action=\"{$redirect_to}\"><input type=\"submit\" value=\"{$webinar_code}\" name=\"webinar_code\" /></form>";

    return $results;
}

add_action( 'wp', 'check_enroll_form_submit' );

function check_enroll_form_submit(){

    if( ! isset( $_POST['webinar_code'], $_POST['webinar_nonce'] ) ){
        return;
    }

    $webinar_code = sanitize_text_field( $_POST['webinar_code'] );
    update_user_meta( get_current_user_id(), $webinar_code, 'true' );
}

I did a couple things here:

  1. Moved the check to update the user’s meta to the wp action
  2. Sanitized the value sent in $_POST (even if you know it’s secure, it’s ALWAYS good to be in the habit of sanitizing any kind of $_POST $_GET or $_REQUEST data)
  3. Instead of passing the value in the name, just pass it in the value (i think you were overthinking that part)

tech