我将使用用户ID然后使用用户IP如果未登录,您可以按如下方式存储结果:
/*
your form validation/submission logiccode goes here
*/
$max_execution_tim = @ini_get(\'max_execution_time\');
$submission_result = array(\'message\' => \'Worked!\', \'status\' => \'success\');
// You can use this function:
// https://stackoverflow.com/a/6718472/1321398
$user_ip = GetIP();
$transient_name = is_user_logged_in() ? "form_submission_user-" .
get_current_user_id() : "form_submission_anonimous-" . $user_ip ;
// save it for a minute
set_transient( $transient_name, $submission_result, 1 * MINUTE_IN_SECONDS );
然后,您可以在输出表单之前进行检查:
$user_ip = GetIP();
$transient_name = is_user_logged_in() ? "form_submission_user-" .
get_current_user_id() : "form_submission_anonimous-" . $user_ip ;
if( $submission_result = get_transient( $transient_name ) ){
//show your message
echo $submission_result[\'message\'];
// delete it to avoid duplicated messages
delete_transient( $transient_name );
}