$wpdb->insert with wordpress shortcode
up vote
0
down vote
favorite
I need help about Wordpress shortcode with $wpdb->insert.
It works, but it run TWICE...
function f_registrazione()
{
$output = '';
if(!$_POST['txtNome'])
{
$output .= "do something in html";
} else {
$output .= "do something else in html";
}
global $wpdb;
$wpdb->insert( mg_nomi, array('des_nome' => $_POST['txtNome']) );
return $output;
}
add_shortcode( 'registrazione', 'f_registrazione' );
This function is written in a custom file linked to them's functions.php
What's wrong? Please help, I don't know how to fix this issue.
I've already tried different solutions, none working...
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
wp_reset_postdata();
wp_reset_query();
Thank you very much.
wordpress custom-wordpress-pages
New contributor
|
show 4 more comments
up vote
0
down vote
favorite
I need help about Wordpress shortcode with $wpdb->insert.
It works, but it run TWICE...
function f_registrazione()
{
$output = '';
if(!$_POST['txtNome'])
{
$output .= "do something in html";
} else {
$output .= "do something else in html";
}
global $wpdb;
$wpdb->insert( mg_nomi, array('des_nome' => $_POST['txtNome']) );
return $output;
}
add_shortcode( 'registrazione', 'f_registrazione' );
This function is written in a custom file linked to them's functions.php
What's wrong? Please help, I don't know how to fix this issue.
I've already tried different solutions, none working...
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
wp_reset_postdata();
wp_reset_query();
Thank you very much.
wordpress custom-wordpress-pages
New contributor
Have you called the shortcode twice?
– Mohammad Ashique Ali
2 days ago
No, only once in one page...
– Matteo Gandini
yesterday
I've added echo $ wpdb-> insert_id; before return $output; it returns "1" in the top of the page, and "2" in the right place.
– Matteo Gandini
yesterday
where you are using this shortcoderegistrazione
?
– Vel
yesterday
Oh, are you working online or on localhost? If online, can you share your URL to look into?
– Mohammad Ashique Ali
yesterday
|
show 4 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I need help about Wordpress shortcode with $wpdb->insert.
It works, but it run TWICE...
function f_registrazione()
{
$output = '';
if(!$_POST['txtNome'])
{
$output .= "do something in html";
} else {
$output .= "do something else in html";
}
global $wpdb;
$wpdb->insert( mg_nomi, array('des_nome' => $_POST['txtNome']) );
return $output;
}
add_shortcode( 'registrazione', 'f_registrazione' );
This function is written in a custom file linked to them's functions.php
What's wrong? Please help, I don't know how to fix this issue.
I've already tried different solutions, none working...
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
wp_reset_postdata();
wp_reset_query();
Thank you very much.
wordpress custom-wordpress-pages
New contributor
I need help about Wordpress shortcode with $wpdb->insert.
It works, but it run TWICE...
function f_registrazione()
{
$output = '';
if(!$_POST['txtNome'])
{
$output .= "do something in html";
} else {
$output .= "do something else in html";
}
global $wpdb;
$wpdb->insert( mg_nomi, array('des_nome' => $_POST['txtNome']) );
return $output;
}
add_shortcode( 'registrazione', 'f_registrazione' );
This function is written in a custom file linked to them's functions.php
What's wrong? Please help, I don't know how to fix this issue.
I've already tried different solutions, none working...
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
wp_reset_postdata();
wp_reset_query();
Thank you very much.
wordpress custom-wordpress-pages
wordpress custom-wordpress-pages
New contributor
New contributor
edited yesterday
Mohammad Ashique Ali
41628
41628
New contributor
asked 2 days ago
Matteo Gandini
11
11
New contributor
New contributor
Have you called the shortcode twice?
– Mohammad Ashique Ali
2 days ago
No, only once in one page...
– Matteo Gandini
yesterday
I've added echo $ wpdb-> insert_id; before return $output; it returns "1" in the top of the page, and "2" in the right place.
– Matteo Gandini
yesterday
where you are using this shortcoderegistrazione
?
– Vel
yesterday
Oh, are you working online or on localhost? If online, can you share your URL to look into?
– Mohammad Ashique Ali
yesterday
|
show 4 more comments
Have you called the shortcode twice?
– Mohammad Ashique Ali
2 days ago
No, only once in one page...
– Matteo Gandini
yesterday
I've added echo $ wpdb-> insert_id; before return $output; it returns "1" in the top of the page, and "2" in the right place.
– Matteo Gandini
yesterday
where you are using this shortcoderegistrazione
?
– Vel
yesterday
Oh, are you working online or on localhost? If online, can you share your URL to look into?
– Mohammad Ashique Ali
yesterday
Have you called the shortcode twice?
– Mohammad Ashique Ali
2 days ago
Have you called the shortcode twice?
– Mohammad Ashique Ali
2 days ago
No, only once in one page...
– Matteo Gandini
yesterday
No, only once in one page...
– Matteo Gandini
yesterday
I've added echo $ wpdb-> insert_id; before return $output; it returns "1" in the top of the page, and "2" in the right place.
– Matteo Gandini
yesterday
I've added echo $ wpdb-> insert_id; before return $output; it returns "1" in the top of the page, and "2" in the right place.
– Matteo Gandini
yesterday
where you are using this shortcode
registrazione
?– Vel
yesterday
where you are using this shortcode
registrazione
?– Vel
yesterday
Oh, are you working online or on localhost? If online, can you share your URL to look into?
– Mohammad Ashique Ali
yesterday
Oh, are you working online or on localhost? If online, can you share your URL to look into?
– Mohammad Ashique Ali
yesterday
|
show 4 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Matteo Gandini is a new contributor. Be nice, and check out our Code of Conduct.
Matteo Gandini is a new contributor. Be nice, and check out our Code of Conduct.
Matteo Gandini is a new contributor. Be nice, and check out our Code of Conduct.
Matteo Gandini is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372535%2fwpdb-insert-with-wordpress-shortcode%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you called the shortcode twice?
– Mohammad Ashique Ali
2 days ago
No, only once in one page...
– Matteo Gandini
yesterday
I've added echo $ wpdb-> insert_id; before return $output; it returns "1" in the top of the page, and "2" in the right place.
– Matteo Gandini
yesterday
where you are using this shortcode
registrazione
?– Vel
yesterday
Oh, are you working online or on localhost? If online, can you share your URL to look into?
– Mohammad Ashique Ali
yesterday