Tag Info

Hot answers tagged

5

I know this is quite an old post and maybe this could help someone. You can replace the class of an element using add_filter(); Here's an example: // filter to replace class on reply link // class name function name add_filter('comment_reply_link', 'replace_reply_link_class'); function replace_reply_link_class($class){ $class ...


5

Filter comment_form_field_comment to add a select element with a label. Add a callback to the action comment_post to save the value. Filter comment_text to show the value for a comment. Sample code: add_filter( 'comment_form_field_comment', function( $field ) { global $wp_roles; $user = wp_get_current_user(); $select = ...


3

When we post an empty anonymous reply, we get the following errors: The part of BBPress that's responsible for handling this, is the bbp_new_reply_handler() function, in the file /bbpress/includes/replies/functions.php. It contains these lines that are of interest to us: // User is anonymous if ( bbp_is_anonymous() ) { // Filter ...


2

You can store these values in cookies and fill them when you are creating form inputs. So in save_comment_meta_data add something like this: $commenter_data = array( 'phone' => $phone, ... ); setcookie('commenter_data', serialize($commenter_data), time()+1209600, COOKIEPATH, COOKIE_DOMAIN, false); And then when you're creating form: ...


2

Don't build your own form and don't modify comments.php - it's purpose is little bit different and I don't think you should include it inside sidebar. Just put comment_form function call in your sidebar template. It takes 2 parameters: args and post_id. So you can do it like this: $args = array( ... // your custom arguments (you can leave it empty ); ...


2

Filter comment_form_defaults and add your code to the textarea. Sample code, not tested: add_filter( 'comment_form_defaults', 'wpse_120049_extend_textarea' ); function wpse_120049_extend_textarea( $args ) { $args['comment_field'] .= '<p>Extra text.</p>'; return $args; }


1

In the first version of your code, you don't check if user is logged in. In the second attempt your logic is wrong, I guess. So your code should look like so: <?php // If CPT and not logged in, display a message: if ( 'CPT' == get_post_type() && !is_user_logged_in() ) { echo '<p class="must-log-in" style="padding-left:20px; ...


1

When I developped this little plugin, I used a part of the code of Danny van Kooten's plugin : 'Recent Facebook Posts'. The content of the plugin folder is : classes / facebook-php-sdk/ base_facebook.php facebook.php fb_ca_chain_bundle.crt class-fcwpc.php fbconnect_wordpress_comments.php fbconnect_wordpress_comments.php: ...


1

Your theme should have a comments.php file. Can you just remove the field there? For instance, my comments.php files has the following code: <p class="field"><label for="url"><?php _e('Website', 'theme1721'); ?> </label><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" ...


1

I was searching for the same solution and at last i found the solution, the below code worked perfectly for me, I wanted to add "btn btn-primary" class to the submit button in comment form. ob_start(); comment_form( $args ); $form = ob_get_clean(); $form = str_replace('class="comment-form"','class="comment-form"', $form); echo ...


1

This is how I've handled passing messages back to the user before: within your current function, set a transient with your message: set_transient( 'admin_notice', 'Please put down your weapon. You have 20 seconds to comply.' ); Then add a new hooked function: function admin_notices() { $notice = get_transient( 'admin_notice' ); if ( $notice ) { ...



Only top voted, non community-wiki answers of a minimum length are eligible