WordPress Search on pluign page - wordpress

I have an plugin to didsplay list of coupon code in WordPress. I would like to place search box for searching coupon code in coupon page.
<form method="get" id="searchform" action="">
<input type="text" value="Search" name="s" id="s" />
<input type="hidden" name="cat" value="5" />
<input type="submit" id="searchsubmit" value="Search" />
</form>
When I click on search button it redirect me to wordpress post page instead of plugin default page.
Suggest me working solution for implement searching in plugin page.

We have to redirect it manually using this form:
<form method="get" action="<?php echo "edit.php?";?>" id="coupon">
<label class="screen-reader-text" for="tag-search-input">Search Coupon Code:</label>
<input type="hidden" name="post_type" value="wpsc-product" /> //required to redirect it coupon page
<input type="hidden" name="page" value="wpsc-edit-coupons" />//required to redirect it coupon page
<input type="search" id="search-input" name="s" value="">
<input type="submit" name="" id="submit" class="button" value="Search Coupon Code">
</form>
After this you will have to grape the result from $_GET['s'] and apply manual search on that file.

Related

Obtain data from a form in wordpress

I'm building a wordpress website using Avada tamplate. I use the Avada login form in which the users insert their username and password. I would like to get the username of the user when he click on the form button and he's redirect to login.php page. I don't understand why I can't do that.
The code of the form (i removed "class" and "style" in order to reduce it) is:
<form name="loginform" id="loginform" method="post" action="http://www.mywebsite.com/es/wp-login.php">
<div>
<div>
<label for="user_login">Username</label>
<input type="text" name="log" placeholder="Username" value="" size="20" id="user_login" />
</div>
<div>
<label for="user_pass">Password</label>
<input type="password" name="pwd" placeholder="Password" value="" id="user_pass" />
</div>
</div>
<div>
<div>
<button type="submit" name="wp-submit">Log in</button>
<input type="hidden" name="user-cookie" value="1" />
<input type="hidden" name="redirect_to" value="login.php" />
<input type="hidden" name="fusion_login_box" value="true" />
<input type="hidden" name="_wp_http_referer" value="/es/area-privada/" /><span></span></div>
<div></div>
</div>
</form>
The login.php code is very simple:
<?php
$username = $_POST['log'];
echo $username;
?>
however the variable $username is blank and doesn't capture the username. Someone can help me please? thanks!

Wordpress Search Function With Mutiple Text Inputs

I need to create a wordpress search function with multiple text inputs
This is the code I have right now, which works fine. It searches for the keyword in the custom post type of "project_posts"
<form role="search" action="/" method="get" id="searchform">
<input type="text" name="s" placeholder="Search Projects"/>
<input type="hidden" name="post_type" value="project_posts" />
<input type="submit" alt="Search" value="Search" />
</form>
But what I want is something like this, with multiple text inputs.
<form role="search" action="/" method="get" id="searchform">
<input type="text" name="s" placeholder="Keyword"/>
<input type="text" name="s" placeholder="Location"/>
<input type="text" name="s" placeholder="Category"/>
<input type="text" name="s" placeholder="Material"/>
<input type="hidden" name="post_type" value="project_posts" />
<input type="submit" alt="Search" value="Search" />
</form>
This is how the client wants it, so that's what I need to provide.
Unfortunately, this code doesn't quite work. It generates this URL
example.com/?s=&s=&s=&s=&post_type=project_posts
And it only uses whatever is in the last search box for the actual search.
I'm a bit stuck with this one, any help is greatly appreciated.

Joomla 3.2 Multiple submit buttons in component

iam struggeling with two submit buttons in my component form.
<button type="submit" class="button"><?php echo JText::_('Save1'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save_1" />
<button type="submit" class="button"><?php echo JText::_('Save2'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save_2" />
The problem ist, each button leads to the controllers function save_2.
If iam changing the order to
<button type="submit" class="button"><?php echo JText::_('Save2'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save_2" />
<button type="submit" class="button"><?php echo JText::_('Save1'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save_1" />
both buttons are executing the function save_1 in the controller.
It is always executing only the task of the last button. What is wrong here?
I would like to execute controllers task1 when I use the button task1, and execute controllers task2 when I use the button task2.
thx Perino
Thank you! I did it now on a similar way:
in the view (i worked with different sub-layouts in this view), id did now
<button type="submit" class="button" name="save_1"><?php echo JText::_('Save1'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save" />
<button type="submit" class="button" name="save_2"><?php echo JText::_('Save2'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save" />
Then in the controller i did
public function save()
{
If (Isset($_POST['save_1']))
{
echo "Button 1 saved"; // here you can do your task for button1
}
If (Isset($_POST['save_2']))
{
echo "Button 2 saved"; //here you can do your task for button2
}
I hope this can also help anybody with same problem.
it looks like both your submit-buttons are in the same form. So the last taks - input will overwrite the first. So either you need to make two forms (probably not what you want?) or you need to handle the click-event depending on which submit-button is clicked, and update the task-variable accordingly, something like:
<button type="submit" class="button"><?php echo JText::_('Save2'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" id="formtask" name="task" value="data.save_2" />
<button type="submit" class="button"
onclick="document.getElementById('formtask').value='data.save_1'">
<?php echo JText::_('Save1'); ?></button>

WP e-commerce remove button

For adding a product to cart by id I've got this code:
<form class="product_form" enctype="multipart/form-data" action="<?php bloginfo('url');?>" method="post" name="1" id="product_143">
<input type="hidden" value="add_to_cart" name="wpsc_ajax_action">
<input type="hidden" value="143" name="product_id">
<button>+</button>
Is there a code to remove a item by id?
I've tried this:
<form action="<?php bloginfo('url');?>" method="post" class="adjustform remove">
<input type="hidden" name="quantity" value="0">
<input type="hidden" name="key" value="0">
<input type="hidden" name="wpsc_update_quantity" value="true">
<input type="submit" value="-">
</form>
But this removes the first item in the cart.

how to post and response to post

I have asp.net button, I want when click to post to the following link
https://www.cashu.com/cgi-bin/pcashu.cgi
with something parameters like the below form do
<form action="https://www.cashu.com/cgi-bin/pcashu.cgi" method="post">
<input type="hidden" name="merchant_id" value="XYZ">
<input type="hidden" name="token" value="66a31cd699d8d9cb454df1f6cec30c2c">
<input type="hidden" name="display_text" value="Baseball Hat">
<input type="hidden" name="currency" value="CSH">
<input type="hidden" name="amount" value="125">
<input type="hidden" name="language" value="en">
<input type="hidden" name="session_id" value="asdasd-234-asdasd">
<input type="hidden" name="txt1" value="item27">
<input type="submit" value="Pay with cashU!">
</form>
I want to do that programatically and catach the return response , and write it on text
any idea how to do that

Resources