How can I change the text on "post comment" button? - php

I am building a site for some therapists using wordpress and am using the comment section of a post for a question and answer with the therapists. However I cannot find where the text is coming from on the "post comment" button. I would like to change it to "Post a Question".
The comments.php in the theme has nothing about it and I cannot find it anywhere in the main wp-comments-post.php
Any help would be great!
Thanks
The web address is http://s416809079.onlinehome.us/ask-the-therapist/
Edit: My confusion has been that I cannot find the 'post comment' anywhere. Also if I just add it then there becomes two buttons and the new one does not actually submit. Here is the code.
<?php
/**
* Comments Template
*
* #file comments.php
* #package Pilot Fish
* #filesource wp-content/themes/pilot-fish/comments.php
* #since Pilot Fish 0.1
*/
if ( post_password_required() ) : ?>
<p class="nocomments"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'pilotfish' ); ?></p>
<?php /* Stop the rest of comments.php from being processed */
return;
endif; ?>
<?php if (have_comments()) : ?>
<h6 id="comments"><?php comments_number(__('No Response to', 'pilotfish'), __('One Response to', 'pilotfish'), __('% Responses to', 'pilotfish')); ?> <i><?php the_title(); ?></i></h6>
<ol class="commentlist">
<?php wp_list_comments('avatar_size=60'); ?>
</ol>
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
<nav class="pager">
<div class="previous"><?php previous_comments_link(__( '‹ previous','pilotfish' )); ?></div><!-- end of .previous -->
<div class="next"><?php next_comments_link(__( 'next ›','pilotfish', 0 )); ?></div><!-- end of .next -->
</nav><!-- end of.pager -->
<?php endif; ?>
<?php else : ?>
<?php if (comments_open()) : ?>
<?php
$fields = array(
'author' => '<p id="comment-form-author">' . '<label for="author">' . __('Name','pilotfish') . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
'<input id="author" name="author" placeholder="'. __('name (required)', 'pilotfish').'" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30" /></p>',
'email' => '<p id="comment-form-email"><label for="email">' . __('E-mail','pilotfish') . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
'<input id="email" name="email" placeholder="'. __('email (required)', 'pilotfish').'" type="text" value="' . esc_attr($commenter['comment_author_email']) . '" size="30" /></p>',
'url' => '<p id="comment-form-url"><label for="url">' . __('Website','pilotfish') . '</label>' .
'<input id="url" name="url" placeholder="'. __('website', 'pilotfish').'" type="text" value="' . esc_attr($commenter['comment_author_url']) . '" size="30" /></p>',
);
$defaults = array('fields' => apply_filters('comment_form_default_fields', $fields));
comment_form($defaults);
?>
<?php endif; ?>

The Comment Form Codex has everything you need to know about customizing the values of a Comment form.
$defaults = array(
'fields' => apply_filters('comment_form_default_fields', $fields),
'label_submit' => __('Post a Question')
);
comment_form($defaults);
That should do what you need.

set the value of the input to <input value="Post a question">

just search for the text post comment and change the value of the button tag for it,
<input name="submit" type="submit" id="submit" value="Post a Question">

Change the value attribute for the following input element:
<input type="submit" value="Post a Question" id="submit" name="submit">
If you do a search all files for "Post Comment" you should find what you are looking for.

Avoid editing your theme's files directly as your changes can be overwritten when you update your theme.
function change_comment_form_submit_label($arg) {
$arg['label_submit'] = 'Post a Question';
return $arg;
}
add_filter('comment_form_defaults', 'change_comment_form_submit_label', 11);
I have added a priority of 11 as the default is 10 and your theme may be changing it with the default priority.
The Comment Form Codex has everything you need to know about customising the values of a Comment form.

Under the class form-submit change the value.
Previous
...
<p class="form-submit">
<input id="submit" type="submit" value="Post Comment" name="submit">
...
Change to
...
<p class="form-submit">
<input id="submit" type="submit" value="Post A Question" name="submit">
...

Related

PHP form + REPLACE INTO mySQL isn't working, but an identical query on another page is functional.. is there something I'm missing?

As the title implies, I have been trying to solve where my issue resides but I have come up empty handed. It does not make any sense to me. I am using a near IDENTICAL if(isset($_POST['submit'])) elsewhere in my wordpress site but for some reason, this one is causing me a headache, and continuously giving me 404 errors when I press the submit button.
My connection to my database is unchanged either (I just changed them in my code below for security reasons).
Lastly - I know I have no action in the form - that is because the action is within the php page. I have it set up like this on another page with fewer <input> and it works just fine.
I have a feeling I am overlooking something super simple but it is eating me away for the past couple days!
Here is my table structure (from Adminer);
Column Type
coin varchar(11)
address varchar(50)
name varchar(50)
serverip varchar(20)
port char(10) [0]
explorer char(90)
api_getbalance char(90)
balance int(40) [0]
collateral int(20)
earning char(30) [0]
status char(15) [ENABLED]
And I have set the Primary Key to address since the REPLACE function requires a Primary/Unique Key set.
<?php
$args = array(
'post_type' => 'product',);
?>
<?php
if(isset($_POST['submit'])) {
$name = $_POST['name'];
$coin = $_POST['coin'];
$serverip = $_POST['serverip'];
$port = $_POST['port'];
$address = $_POST['address'];
$explorer = $_POST['explorer'];
$apigetbalance = $_POST['apigetbalance'];
$collateral = $_POST['collateral'];
$con2 = mysqli_connect("IP","USER","PASS","DB");
$update = "REPLACE INTO wp_shared_nodes (address, name, serverip, port, coin, explorer, api_getbalance, collateral) VALUES (?,?,?,?,?,?,?,?)";
$stmt = mysqli_prepare($con2,$update);
if ($stmt) {
mysqli_stmt_bind_param($stmt, 'ssssssss', $address, $name, $serverip, $port, $coin, $explorer, $apigetbalance, $collateral);
$ok = mysqli_stmt_execute($stmt);
if ($ok) {
echo "<strong> <i class='fa fa-check' aria-hidden='true'></i> The node information was added correctly.</strong>";
} else {
echo 'Data Not Updated';
error_log(mysqli_stmt_error($stmt));
}
mysqli_stmt_close($stmt);
} else {
error_log(mysqli_error($con2));
}
mysqli_close($con2);
}
?>
<?php
echo "<p><h5>Add/Change Node:</h5>";
$loop = new WP_Query( $args );
echo '<form method = "post">';
echo '<div class="row"><div class="column">';
//coin name
echo '<p style="margins:0"><h5>Coin Name</h5>';
echo '<p><input type="text" placeholder="Insert Coin Name" id="name" name="name" size="40" /></p>';
//coin ticker
echo '<p style="margins:0"><h5>Ticker</h5>';
echo '<p><select id="coin" name="coin">';
echo '<option>-- Select coin--</option>';
while ( $loop->have_posts() ) : $loop->the_post();
global $product;
echo '<option value=' . $product->get_sku() . '>' . $product->get_sku() . ' </option>';
endwhile;
echo '</select>';
//wallet address
echo '<p style="margins:0"><h5>Wallet Address</h5>';
echo '<p><input type="text" placeholder="Address" id="address" name="address" size="40" /></p>';
//Collateral
echo '<p style="margins:0"><h5>Collateral</h5>';
echo '<p><input type="text" placeholder="Amount" id="collateral" name="collateral" size="10" /></p>';
echo '</div>';
echo '<div class="column">';
//Server IP
echo '<p style="margins:0"><h5>Server IP</h5>';
echo '<p><input type="text" placeholder="IP Address" id="serverip" name="serverip" size="20" /></p>';
//Server Port
echo '<p style="margins:0"><h5>Port</h5>';
echo '<p><input type="text" placeholder="Port" id="port" name="port" size="10" /></p>';
//Explorer
echo '<p style="margins:0"><h5>Explorer link to default address</h5>';
echo '<p><input type="text" placeholder="e.g. https://explore.creativecoin.design/address/" id="explorer" name="explorer" size="50" /></p>';
//Ext/getbalance
echo '<p style="margins:0"><h5>API link for balance</h5>';
echo '<p><input type="text" placeholder="e.g. https://explore.creativecoin.design/ext/getbalance/" id="apigetbalance" name="apigetbalance" size="50" /></p>';
echo '</div></div>';
echo '<br><input type="submit" name="submit">';
echo '</form>';
?>
This should really be a comment, not an answer, but I don't have enough points yet to comment.
I feel the problem is likely in your "action" for the form. Since it's not in your code, I can't test it. But, it's the action that determines which page gets posted to when you submit. Since you're getting a 404 error, that would imply that you've set the action to a page that doesn't exist or you've used the wrong path. If the error were in your function, you'd get to the right page, so no 404, and then you'd get sql or php errors or unexpected results, but not a 404.
I created a very simple test page, using your exact submit input, and it works as I'd expect:
<html>
<body>
<?php
if(isset($_POST['submit'])) {
echo "submit isset";
} else {
echo "submit !isset";
}
?>
<form method="post">
<input type="submit" name="submit">
</form>
</body>
</html>
If you'd like to post the "action" statement, I might be able to figure out what is wrong with it, but, it may be as simple as a typo.
A 404 error is an HTTP status code that means that the page you were trying to reach on a website couldn't be found on their server.
<p><h5>Add/Change Node:</h5>
<?php $loop = new WP_Query( $args ); ?>
<form action="submit.php" method = "post">
<div class="row"><div class="column">
//coin name
<p style="margins:0"><h5>Coin Name</h5>`<br>
<p><input type="text" placeholder="Insert Coin Name" id="name" name="name" size="40" /></p>
//coin ticker
<p style="margins:0"><h5>Ticker</h5>
<p><select id="coin" name="coin">
<option>-- Select coin--</option>
<? php while ( $loop->have_posts() ) : $loop->the_post();
global $product;
echo '<option value=' . $product->get_sku() . '>' . $product->get_sku() . ' </option>';
endwhile;
?>
</select>
//wallet address
<p style="margins:0"><h5>Wallet Address</h5>
<p><input type="text" placeholder="Address" id="address" name="address" size="40" /></p>
//Collateral
<p style="margins:0"><h5>Collateral</h5>
<p><input type="text" placeholder="Amount" id="collateral" name="collateral"
size="10" /></p>
</div>
<div class="column">
//Server IP
<p style="margins:0"><h5>Server IP</h5>
<p><input type="text" placeholder="IP Address" id="serverip" name="serverip"
size="20" /></p>
//Server Port`<br>
<p style="margins:0"><h5>Port</h5>
<p><input type="text" placeholder="Port" id="port" name="port" size="10" />
</p>
//Explorer
<p style="margins:0"><h5>Explorer link to default address</h5>
<p><input type="text" placeholder="e.g. https://explore.creativecoin.design/address/" id="explorer" name="explorer" size="50" /></p>
//Ext/getbalance
<p style="margins:0"><h5>API link for balance</h5>
<p><input type="text" placeholder="e.g. https://explore.creativecoin.design/ext/getbalance/" id="apigetbalance" name="apigetbalance" size="50" /></p>
</div></div>
<input type="submit" name="submit">
</form>
form action is needed thats why its show 404 error
you may also try
action=""
action="same page url"

Shortcode with form shows duplicate entry fields

I created a search form for my custom post types and I want to be able to place it anywhere on my site, so I created a shortcode. The vanilla form works fine, but in a shortcode, it's displaying duplicate fields. Can anyone see why it would do this? The top 3 fields are duplicates of the fields in the lower form. You can see the result at http://autismva.teebark.com/resource-finder-3.
You can see the vanilla form at http://autismva.teebark.com/resource-finder2
function resource_search_form( $form ) {
$form = '<form id="category-select" class="category-select" method="post" action="' . esc_url(admin_url('admin-post.php')) . '" >' .
wp_dropdown_categories( 'show_count=1&hierarchical=1&depth=2&show_option_none=Select by category&name=$cat_id&taxonomy=resource_cat' ) . '<br>' .
wp_dropdown_categories( 'show_count=0&hierarchical=1&depth=1&show_option_none=Select by age&name=$age_id&taxonomy=resource_age' ) . '<br>' .
wp_dropdown_categories( 'show_count=0&exclude=128&show_option_none=Select by region&name=$region_id&taxonomy=resource_region' ) . '<br>' .
'<input type="text" name="s" placeholder="Search by keyword" /><br>
<input type="text" name="tag_name" placeholder="Search by tag" />
<input type="hidden" name="action" value="resource_search_cat2" />
<button type="submit" > Search </button>
</form>';
return $form;
}
add_shortcode('resource_search', 'resource_search_form');
**The vanilla form:**
<form id="category-select" class="category-select" method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" >
<?php wp_dropdown_categories( 'show_count=1&hierarchical=1&depth=2&show_option_none=Select by category&name=$cat_id&taxonomy=resource_cat' ); ?><br>
<?php wp_dropdown_categories( 'show_count=0&hierarchical=1&depth=1&show_option_none=Select by age&name=$age_id&taxonomy=resource_age' ); ?><br>
<?php wp_dropdown_categories( 'show_count=0&exclude=128&show_option_none=Select by region&name=$region_id&taxonomy=resource_region' ); ?><br>
<input type="text" name="s" placeholder="Search by keyword" /><br>
<input type="text" name="tag_name" placeholder="Search by tag" />
<input type="hidden" name="action" value="resource_search_cat2" />
<button type="submit" > Search </button>
</form>
I hope this will work for you.
// write this action in your "after_setup_theme" hook
add_action( ' woocommerce_single_product_summary ' , ' your_function_name ' , 10 );
//define your function that contains the removal action hook.
function your_function_name()
{
remove_action( ' woocommerce_single_product_summary ' , ' woocommerce_template_single_add_to_cart ' , 30 );
}

Wordpress how to get post ID outside of the loop

I have a custom post type called 'bookings' that saves several fields of meta data to wp_postmeta.
I have a page that displays all the entries from this custom post type, i.e. all the bookings.
Here is the code to display my bookings:
<?php
$current_user = wp_get_current_user();
$args = array(
'post_type' => 'bookings',
'meta_query' => array(
array(
'key' => 'wedding_user',
'value' => $current_user->display_name,
'compare' => '=',
)
)
);
// Welcome
echo '<div class="user_avatar">'.get_avatar( $current_user->ID, 32 ).'</div>';
echo '<div class="user_welcome"><p>Hello '.$current_user->display_name.' <span class="user_id">(ID# '.$current_user->ID.')</span></p>';
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
if (get_post_meta( $the_query->post->ID, 'wedding_hidden_is_completed', true )==1) {
$is_complete = 'Form Complete <br /><span class="small">('.get_post_meta( $the_query->post->ID, 'wedding_hidden_date_completed', true ).')</span>';
} else {
$is_complete = 'Not Complete';
}
echo '<p class="booking_id">Booking ID: DISTR' . $the_query->post->ID . '</p>';
echo '<ul class="show_bookings">';
echo '<li>' . get_post_meta( $the_query->post->ID, 'wedding_name', true ) . '</li>';
echo '<li>' . get_post_meta( $the_query->post->ID, 'wedding_date', true ) . '</li>';
echo '<li>' . get_post_meta( $the_query->post->ID, 'wedding_package', true ) . '</li>';
echo '<li>£' . get_post_meta( $the_query->post->ID, 'wedding_price', true ). '</li>';
echo '<li>' . get_post_meta( $the_query->post->ID, 'wedding_payment_due_date', true ) . '</li>';
echo '<li>' . $is_complete . '</li>';
echo '<li>Is Viewed?</li>';
echo '<li>Actions';
echo '<ul class="actions-sub-menu">';
echo '<li>Fill out booking form</li>';
echo '<li>Pay deposit</li>';
echo '<li>Pay remaining balance</li>';
echo '<li>Email a copy of your receipt</li>';
echo '<li>View booking form</li>';
echo '</ul>';
echo '</li> <!--end actions-sub-menu-->';
echo '</ul>';
?>
<div class="pay_deposit">
<?php
require DISTRACTIONS_LOGIN_PLUGIN_DIR . 'includes/payments/deposit.php';
?>
</div> <!-- end pay deposit -->
<?php
}
} else {
echo '<p>No bookings found</p>';
}
/* Restore original Post Data */
wp_reset_postdata();
?>
under each booking is a paypal payment button - it uses paypal IPN, so nothing too complex (you will see the required file in the "pay_deposit" div).
Here is my paypal payment form:
<?php
$paypal_url='https://www.sandbox.paypal.com/cgi-bin'; //
$paypal_id='malik#thedistractionsband.co.uk'; // Business email ID
$booking_form_id = $the_query->post->ID;
$total_amount = get_post_meta( $the_query->post->ID, 'wedding_price', true );
$deposit_amount = $total_amount*0.2;
?>
<h3>Pay Deposit</h3>
<p>Your deposit aount of £<?php echo $deposit_amount; ?> ...</p>
<form action="<?php echo $paypal_url; ?>" method="post" name="frmPayPal1">
<input type="hidden" name="business" value="<?php echo $paypal_id; ?>">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="<?php echo get_post_meta( $the_query->post->ID, 'wedding_name', true ); ?> - 20% Deposit">
<input type="hidden" name="item_number" value="DISTR<?php echo $booking_form_id; ?>">
<input type="hidden" name="credits" value="510">
<input type="hidden" name="userid" value="<?php echo $current_user->ID; ?>">
<input type="hidden" name="amount" value="<?php echo $deposit_amount; ?>">
<input type="hidden" name="cpp_header_image" value="http://www.thedistractionsband.co.uk/files/2015/08/LOGO-1.1-1024x304.png">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="handling" value="0">
<input type="hidden" name="cancel_return" value="<?php echo get_site_url()."/payment-cancel/"; ?>">
<input type="hidden" name="return" value="<?php echo get_site_url()."/my-bookings/"; ?>">
<input name="notify_url" value="<?php echo DISTRACTIONS_LOGIN_PLUGIN_URL ?>includes/payments/paypal-ipn.php" type="hidden">
<input type="submit" border="0" name="submit" value="Pay Now" alt="PayPal - The safer, easier way to pay online!">
<div class="cards"><i class="fa fa-cc-amex"></i> <i class="fa fa-cc-mastercard"></i> <i class="fa fa-cc-visa"></i> <i class="fa fa-credit-card"></i> <i class="fa fa-cc-paypal"></i></div>
</form>
When a payment is made, it uses the following file to communicated with paypal and update my database - paypal-ipn.php
<?php
// Make wordpress functions available - so we can write to the db etc
$parse_uri = explode( 'wp-content', $_SERVER['SCRIPT_FILENAME'] );
require_once( $parse_uri[0] . 'wp-load.php' );
global $wpdb;
update_post_meta($booking_id, 'deposit_paid', 1);
?>
My issue is in this file. The update_post_meta function is used to add a '1' to the deposit_paid column in my wp_postmeta db table. The issue I have is, how do I define the $booking_id - making sure that it is for the booking that has been paid for.
For example, on my page that lists all my bookings, if the first has post_id 10 and I pay for that, how do I make sure that the 'deposit_paid' entry for post_id 10 is updated?
Figured it out, I need to use:
$booking_id = $_POST['item_number'];
To get the item number sent to paypal (which is the same as the post id)

Codeginiter retriveing values of checked checkbox

Im developing form application. Inside the form there are textboxes,textarea, checkboxes checkboxes are populated according to array. and i pass all the form values to controller . Values of textboxes, texarea print correctly. Problem is there only prints last value of checked checkbox. how do i print all checked box values. please help me & please find the code i used.
askQuestion.php (view)
<?php echo form_open('homepage/test'); ?>
<p>
<div>
<div class="form-group">
Question Title:<br/>
<input type="text" value="" name="">
</p>
<div>
<div class="form-group">
<p>
Description: <br/>
<textarea name="decription" rows="5" cols="100"> </textarea>
</p>
<?php
$chk_group =array('1' => 'red',
'2' => 'aa',
'3' => 'bb',
'4' => 'cc',
'5' => 'dd'
);
var_dump($chk_group);
for ($i=1 ; $i<=count($chk_group);$i++)
{
$val =$chk_group[$i];
echo "<br>";
echo '<input type="checkbox" value="' . $val . '" name="chk_group">' . $val;
echo "</br>";
}
?>
</div>
<div class="form-group">
Declare new Tags:<br/>
<input type="text" value="" name="tag">
</p>
</div>
<p>
<input type="submit" class="btn btn-success btn-block" value="Post Your Question" id="postQuestion">
</p>
<?php echo form_close();?>
homepage.php (controller)
public function test() {
echo "test";
$name = $this->input->post('tag');
print_r($name);
$des = $this->input->post('decription');
print_r($des);
$data = $this->input->post('chk_group');
var_dump($data);
/* foreach ($this->input->post('chk_group') as $r) {
echo $r;
}
*/
}
You should use array to name the check boxes. You used loop to generate the check boxes & used same name for all. For this you got only last one value.
echo '<input type="checkbox" value="' . $val . '" name="chk_group[]">' . $val;

WordPress : Password Protected Page (2)

I just upgraded my site to a new version WordPress 3.9.2. I noticed that one of my page is not working the way it usually does. This page is password protected and I made changes on how it looks. When I upgraded, it doesn't work anymore. In the password protected page, I have this code:
<?php
echo "<script type='text/javascript'>\nwindow.location = 'http://www.google.com'</script>";
?>
The purpose of that one is to redirect to another page. And they go hand in hand with this code below.
Here is my old code:
<?php
function my_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post">
' . __( "To view this protected post, enter the password below:" ) . '
<label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
</form>
';
return $o;
}
add_filter( 'the_password_form', 'my_password_form' );
?>
Before the upgrade, after inputting the password it redirects me to another page, which is how I wanted it to work. But take note of the action attribute of form. In the WP 3.9.2, wp-pass.php does not exist anymore so I was looking for another code. I saw this line:
action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '"
But after inputting the password, it redirects me to the wp-login which is not what I wanted. I need help with this, which works the same way with the old code I'm using. I am not going to downgrade my WP or install any plugin. I just want the value of the action="" changed. Thanks!
I already found the answer. Maybe my files weren't compatible that's why it didn't work but here is the full code.
<?php
function my_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post">
' . __( "To view this protected post, enter the password below:" ) . '
<label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
</form>
';
return $o;
}
add_filter( 'the_password_form', 'my_password_form' );
?>
NOTE : I am using WordPress 3.9.2
I had the same problem and i found a solution
1) Set your page private with a password
2) Insert this form in an other page (typique postpass wordpress form) :
<form action="https://exemple.com/wp-login.php?action=postpass" class="post-password-form" method="post" id="go-pro-espace">
<input name="post_password" id="exemple" type="password" size="20" /><br />
<input type="submit" value="submit">
</form>
3) Change your /wp-login.php file (root directory, at this time, this is located line 460) :
from:
wp_safe_redirect( wp_get_referer() );
to:
wp_safe_redirect( "https://exemple.fr/your-protected-page" );
Take a look to the answer: Wordpress protected page, POST form on a other page

Categories