Thanks. I tweaked your script a little bit to make it work.
add_action( 'wp_enqueue_scripts', function () {
$handle = 'totalcontest-frontend';
$script_url = plugins_url( 'totalcontest/assets/dist/scripts/frontend.js', __FILE__ );
wp_enqueue_script( $handle, $script_url, array(), null, true );
if(isset($_SESSION['team_id'])) { $teamId = $_SESSION['team_id']; } else { $teamId = 0; }
$inline_script = sprintf(
'document.addEventListener("DOMContentLoaded", function() {
var teamIdField = document.querySelector("#id_equipe-field");
if (teamIdField) {
teamIdField.value = "%d";
}
});',
$teamId,
$teamId
);
wp_add_inline_script( $handle, $inline_script );
}, 20 );
Now, is there a way to display this as a pre-filled, non-modifiable input field in the Participate page? (that I still will be able to display on the Submission page)
-
This reply was modified 2 months, 3 weeks ago by cyberlp23.