I'm developing a plugin in wordpress, there is data that needs to be listed by search but I can't get them with the get parameter.
I can send with the post parameter, but when the user refreshes the page, she has to search again according to the order number.
Following my code:functions.php
add_action('admin_menu', 'testPluginAdminMenu');
function testPluginAdminMenu()
{
add_menu_page('Return Request',
'Return Request',
'manage_options',
'list',
'myFunction'
);
add_submenu_page(
'null',
'Return Request List',
'Return Request List',
'manage_options',
'listAll',
'myFunctionList');
}
index.php
<?php
function myFunctionList(){
if(isset($_GET['request_order'])){
echo $search = $_GET['request_order'];
}
}
function myFunction(){ ?>
<form method="get" action="<?php echo admin_url('admin.php?page=listAll&request_order='.$_GET['request_order'] ) ?>">
<input type="text" name="request_order" placeholder="Search Order Number..">
<button type="submit" >Search</button>
</form>
<?php } ?>
Output from url: localhost/wordpress/wp-admin/admin.php?request_order=7481
page=listAll not appearing on url
Thank you advance.
Can you try something like this
$qs = array(
'page' => 'listAll',
'request_order' => $_GET['request_order']
);
$qs = http_build_query($qs, null, "&", PHP_QUERY_RFC3986);
<?php echo admin_url('admin.php?' . $qs ) ?>
UPDATE 1
<form method="get" action="<?php echo admin_url('admin.php?page=listAll&request_order='.$_GET['request_order'] ) ?>">
<input type="text" name="request_order" placeholder="Search Order Number..">
<input type="hidden" name="page" value="listAll" />
<button type="submit" >Search</button>
</form>
Related
I have custom post type called "forms", and has a sub-menu page which contains form, to add a name.
add_action('admin_menu', 'form_builder_add');
function form_builder_add() {
//create new top-level menu
add_submenu_page('edit.php?post_type=forms', 'Add name', 'Add name', 'manage_options', 'form-dashboards', 'add_names');
}
function add_names() {
echo
'
<form method="post" action="">
<input type="text" name="name" id="name" />
<input type="submit" value="submit" />
</form>
';
}
and I have shortcode and foocode where I want to spit out the values from the form.
add_shortcode( 'foocode', 'prefix_foocode' );
function prefix_foocode() {
return 'This is '. $_POST['name'] . ' testing';
}
So when I call the shortcode from the post, it should have the value of name from the form.
[foocode]
This is example name testing.
I have 2 functions - one generates the form on my main page and the other processes the submitted form. This is the Braintree sandbox API and their method is this: take in user info and submit to Braintree server, BT server returns a payment method nonce to me which I can then use to POST and view the transaction in my sandbox control panel. However, the form isn't being submitted and I'm not sure at what point in the process the whole submission is failing. NOTE - I am submitting the form to the same PHP file where the form is located.
I still need help on this...
ask.php - This is the page where I call both functions
<div>
<?php
fd_bt_form();
fd_process_trans();
?>
</div>
find-do-for-anspress.php
$FD_Braintree_Keys = array(
Braintree_Configuration::environment('sandbox'),
Braintree_Configuration::merchantId('A'),
Braintree_Configuration::publicKey('B'),
Braintree_Configuration::privateKey('C')
);
function fd_bt_form()
{
$class_bt_token = new Braintree_ClientToken();
$clientToken = $class_bt_token->generate();
?>
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
<script>
braintree.setup(
'<?php echo $clientToken ?>',
'custom', {
id: 'checkout',
});
</script>
<?php
echo
'<form id="checkout" action="" method="POST">
<p>
<label><font size="5">Amount:</font></label>
<input type="text" size="4" name="amount" id="amount" />
</p>
<input data-braintree-name="number" value="378282246310005">
<br> <br />
<input data-braintree-name="expiration_month" value="05">
<input data-braintree-name="expiration_year" value="17">
<br> <br />
<input data-braintree-name="cvv" value="531">
<br> <br />
<input type="submit" id="submit" value="Pay">
</form>';
echo $_POST["payment_method_nonce"];
global $bt_nonce;
$bt_nonce = $_POST["payment_method_nonce"];
return $bt_nonce;
}
function fd_process_trans() {
$FD_Braintree_Keys;
$nonce = $_POST["payment_method_nonce"];
$amount = $_POST["amount"];
$result = Braintree_Transaction::sale(array(
'amount' => $amount,
'paymentMethodNonce' => $nonce,
'options' => array(
'submitForSettlement' => True,
),
));
if ($result->success) {
echo "Success!";
}
else {
echo "Transaction failed.";
}
}
I'm having what im sure is a simple issue but i can't manage to figure it out.
I'm coding a theme options page for my wordpress template and i've managed to get it where the values are saved and i can use them on the site but whenever i reload the theme options page all the form fields are blank and any previously applied settings are gone. My code is below.
<?php
//Theme Options Functionality is Below
if (get_option('pardue_theme_options')){
$theme_options = get_option('pardue_theme_options');
} else {
add_option('pardue_theme_options', array(
'sidebar2_on' => true,
'footer_text' => 'Made by William'
));
}
?>
<?php add_action('admin_menu', 'theme_page_add');
function theme_page_add() {
add_submenu_page('themes.php', 'Pardue Theme Options', 'Theme Options', 'administrator', 'themeoptions', 'theme_page_options');
}
function theme_page_options() {
global $theme_options;
$new_values = array(
'footer_text' => htmlentities($_POST['footer_text'], ENT_QUOTES),
);
update_option('pardue_theme_options', $new_values);
$theme_options = get_option('pardue_theme_options');
echo '<div class="wrap">';
echo '<h2>Theme Options</h2>';
?>
<form action="themes.php?page=themeoptions" method="post">
<label for="footer_text">Footer Text: </label><input name="footer_text" id="footer_text" value="<?php echo $theme_options['footer_text']; ?>" /> <br /> <br />
<label for="sidebar_checkbox">Sidebar 2 on: </label> <input name="sidebar_checkbox" id="sidebar_checkbox" value="on" type="checkbox" /> <br /> <br />
<input type="submit" value="Update Options" name="submit" />
</form>
<?php
echo '</div>';
}
?>
I found a good solution for coding my theme options. The plugin at the link below makes it very easy to code up theme options.
Link to plugin
Documentation is included when you activate the plugin.
not sure if this is possible, but what i need to do is take the data from my text area and let the user post that to their wall.
my code snippet
<div align="center">
<form method="GET" action="translate.php">
<textarea name="status2" cols="50" rows="5"<input type="text"/>
<?php echo str_ireplace(array ('old','awkward','all','again','behind','along','alright','hello','among','children','yes','child','kids','food','barnard castle','beer','book','blow','beautiful','bird','burst','brown','burn','boots'),
array ('auld', 'aakwad', 'aall','agyen','ahint','alang','alreet','alreet','amang','bairns','aye','bairn','bairns','bait','barney','beor','beuk','blaa','bonny','bord','borst','broon','bourn','byeuts'),$status); ?>
</textarea><br>
<input type="submit" value="post to wall" />
</form>
</div>
<?php
$args = array(
'message' => 'Hello World',
'link' => 'http://apps.facebook.com/geordie-status/',
'caption' => 'Translate from English to Geordie'
);
$post_id = $facebook->api("/$uid/feed", "post", $args);
?>
the default message 'Hello World' posts to the wall, but i would like to replace that with the text in 'status2' text area. Is this possible?
Thanks
<textarea name="status2" cols="50" rows="5"<input type="text"/>
Doesn't make sense.
Guessing that your textarea is well coded in your real snippet. You should have the value of the textarea inside $_GET['status2'], so change traslate.php:
$args = array(
'message' => $_GET['status2']
...
this is the code i've written for the test:
index.html
<form method="GET" action="server.php">
<textarea name="status2"></textarea>
<input type="submit" value="go"/>
</form>
server.php
<?
print_r($_GET);
?>
I was using the code below as a Plugin to create a "Options Menu Page" for wordpress:
add_action('admin_init', 'cardin_options_init' );
add_action('admin_menu', 'cardin_options_add_page');
function cardin_options_init(){
register_setting( 'cardin_options_options', 'cardin_options');
}
function cardin_options_add_page() {
add_options_page('Cardin Options', 'Cardin Options', 'manage_options', 'cardin_options', 'cardin_options_do_page');
}
function cardin_options_do_page() {
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br></div>
<h2>Cardin Options</h2>
<form method="post" action="options.php">
<?php settings_fields('cardin_options_options'); ?>
<?php $options = get_option('cardin_options'); ?>
<table class="form-table">
<tr valign="top"><th scope="row">Information</th>
<td><input type="text" name="cardin_options[information]" value="<?php echo $options['information']; ?>" /></td>
</tr>
</table>
<input type="submit" class="button-primary" name="submit" value="<?php _e('Save Changes') ?>" />
</form>
</div>
<?php
}
It's working how it should, but, later I decided to create my Own Plugin Menu Page, not a 'Settings' sub-menu, then, I changed the line below:
add_options_page('Cardin Options', 'Cardin Options', 'manage_options', 'cardin_options', 'cardin_options_do_page');
to:
add_menu_page('Cardin Options', 'Cardin Options', 'manage_options', 'cardin_options', 'cardin_options_do_page');
It worked, but when i click "Save Changes" the "Settings Updated" message doesn't display anymore. What should I do to make it display again?
Thanks alot in advance and sorry for the bad english.
<?php if($_POST['oscimp_hidden'] == 'Y') { ?>
<div id="message" class="updated">
<p><strong><?php _e('Settings saved.') ?></strong></p>
</div>
edit:
heres a guide: http://net.tutsplus.com/tutorials/wordpress/creating-a-custom-wordpress-plugin-from-scratch/
search for: if($_POST['oscimp_hidden'] == 'Y') {