I'm trying to hook onto the WP Gravityforms plugin's not found message.
I've found a hook(gform_form_not_found_message) for this but it doesn't seem to be firing. What am I doing wrong here?
My code:
function notfoundmessage($message, $id){
$message = 'test';
return $message;
}
add_filter( 'gform_form_not_found_message', 'notfoundmessage', 10, 2);
I tried several thing like writing the function inline, including it from the main plugin file, including it in an oop way but none of them seem to work. I was thinking that maybe I need to require a gravityforms Class but I can't find anything about that in the documentation.
Link to the hook in the documentation
It turned out the filter isn't applied yet in the version I'm using. For other people having this issue, make sure you are using the latest version of Gravityforms.
Related
I have the unset function in my functions.php theme file and WordPress no longer allows me to save my code in the editor.
I'm using it to unset product tabs on WooCommerce as per this code (found on the WooCoomerce site - https://docs.woocommerce.com/document/editing-product-data-tabs/):
add_filter( 'woocommerce_product_tabs', 'custom_remove_product_tabs', 98 );
function custom_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
return $tabs;
}
With this code in I get the generic error of: "Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP." when saving my functions.php file. If I comment out the line with the unset function is saves just fine.
It does work on the site if I save this code using FTP etc so I appreciate some may say just do that, but I like to quickly edit things inside WordPress sometimes which is no longer possible so want to understand why it's happening (and WordPress have docs on using this function themselves so it's driving me mad!). I've tried adding a standard php unset function with a generic variable to check it's not WooCommerce related but this doesn't work either.
Am I missing something? If not, is it a server setting? We're using PHP 7.4 on a litespeed server so should be up to date. I'm not sure if there is a way to see a more detailed error log from this issue so if there is any help finding it would be great.
Thanks for any help!
I use a plugin (Popup Builder) on my WordPress site. Whenever I create a new popup with the plugin, it creates a shortcode for that popup. I want to call on that shortcode from within the theme functions.php file. But I can't seem to get it to work properly.
The shortcode runs only if conditions are met. And in this example it's when a visitor access the site for the first time. I then check for a certain cookie and if that cookie does not exist, the popup will fire up and force the visitor to choose one option from a list of options, and then the cookie will be set with the correct value, once they do.
However I cant seem to find a solution that fires the popup at all. An I also get this notice: Notice: do_shortcode_tag was called incorrectly. Attempting to parse a shortcode without a valid callback:
function check_for_cookies() {
// Check if cookie is already set
if(isset($_COOKIE['tln_valgt_fylke'])) {
// Do this if cookie is set
$string .= 'Hi, and welcome back!' ;
return $string;
} else {
// Do this if the cookie doesn't exist
$shortcode = do_shortcode("[sg_popup id=163]");
return $shortcode;
}
}
add_action('init', 'check_for_cookies');
What am I doing wrong, and what if this is not a good way of accomplishing what I want, then what is?
This is just a guess
But, I think its a timing issue. You are using the init action to hook into another plugins shortcodes. It's possible that plugin has not yet registered it's shortcode via add_shortcode or if it has registered it, it may not have "included" the file that defines the callback for it (for whatever reason).
In fact it seems likely because:
do_shortcode_tag was called incorrectly. Attempting to parse a shortcode without a valid callback
This indicates the shortcode was called and no callback existed for it. This is not a problem with your code per say. But it says that the plugin has not yet loaded the file that contains the callback.
You could test this by hooking into an action that happens later in the execution chain, after you know all plugins have been loaded and initialized. Like even wp_head
Perhaps you could even get away with changing the priority of the hook:
add_action('init', 'check_for_cookies', 20); //default is 10
This way it's triggered at the end of init, but even then it may be too soon. The only real way to know is to look at the code for the plugin and find out when it's registering it's "stuff". An easy way to do that is add this code to the plugins shortcode callback:
try{
throw new \Exception();
}catch(\Exception $e){
die("<pre>{$e->getTraceAsString()}</pre>");
}
This will throw and then catch an exception, and then output the stacktrace. Which may show you exactly where the shortcode is being setup. You'll have to trigger the callback (obviously) for it to work. You can also use print_r(debug_backtrace()) but it's much harder to read IMO.
PS I been doing a lot of WP work lately and I just had an issue with action timing ... lol. That was why I thought of it, I spent the last 2 days refactoring code. In my case I an replacing the add/edit/profile parts of the user system on both the front and back end. It's a sort of subuser plugin. And there is a lot of competing actions related to that if you know what I mean...
I have inherited a custom wordpress theme and am doing a few changes to it (all cosmetics of changing city names, etc) , but at the bottom of a post I get the error : "Fatal error: Call to undefined function get_meta()"
In my functions.php I have this:
function bardetails(){
$web = get_meta('web');
$email = get_meta('email');
//...
}
I have a Java background but am new to php and wordpress. I dont see anywhere else this function is called, but must be tied to a post.
Have looked and can find a lot of problems about "get_post_meta()" and "meta()" but nothing about this. It also seems to be working on the other site the theme is on. I used FTP to pull over everything and all the other parts of the site seem to work fine. Looked at the database for something that could help with no luck, and also have tried to find if this is some kind of library, as the intention of the function is clear and thats to grab the website/email of the post.
So is this just a straight custom function? And if so were should it be defined in a php/wordpress setup?
It was due to a plugin that was not installed. "More Fields" By Henrik Melin, Kal Ström is a seemingly defunct plugin that was needed that allows you to use "get_meta()". For now, I just copied over the plugin but seems like I need to find an alternative going forward.
I am using woocommerce plugin in my wordpress site. I want to remove a function named 'woocommerce_checkout_coupon_form' which is hooked in to the action 'woocommerce_before_checkout_form'.
I tried adding the below code in my theme functions.php
add_action('init','remove_coupon_text',10);
function remove_coupon_text() {
remove_action('woocommerce_before_checkout_form','woocommerce_checkout_login_form',10);
}
But this is not working. Any idea?
Sorry it was a mistake from my side. I used the wrong function name. The function name I intended to remove was 'woocommerce_checkout_coupon_form'. The issue is fixed now.
Try this
remove_all_actions( $tag, $priority );
Try increasing the priority.
remove_action('woocommerce_before_checkout_form','woocommerce_checkout_login_form',1 - 10);
Edit: Follow the comments below and dont use this as it is, what i meant by increasing priority was to gradually increase the priority till it matches the time when function was added, when it does match you will automatically see the results else it just wont work. Thank you everyone for making it clear.
I recently purchased a Wordpress theme and having some problems with importing a feature from another theme (from the same author).
The author of the themes helped me a lot with importing some stuff to the new theme. While both themes share many similarities, there's still some tweaking that needs to be done.
One of the issues I'm currently facing is with a PHP file I imported from the original theme to the new one. Both Wordpress themes work with minisites, but the author coded them differently for each Wordpress.
When I copy/paste boxes.php from the old theme to the new theme, I get this error message:
Fatal error: Call to undefined function it_get_minisite() in /home/vincevc73/domains/quirk.be/public_html/wp-content/themes/explicit/inc/boxes.php on line 13
The author told me I had to exclude this, but I have no idea how to do this. I read I had to put /*-*/ around the functions to exclude it, but I'm not sure where to put these marks exactly
The it_get_minisite function appears three times in the file
$minisite = it_get_minisite($post->ID);
if($minisite)
{
#override general theme options with minisite-specific options
$boxes_layout = $minisite->boxes_layout;
}
#get the current minisite $minisite = it_get_minisite($post->ID);
if($minisite)
{
#add post type to query args
if(it_targeted('boxes', $minisite))
$boxesargs['post_type'] = $minisite->id;
}
$minisite = it_get_minisite(get_the_ID(), true);
I think he meant that you should remove all the code which requires this function. But then you will also have to remove the code which requires "$minisite" too. But that's only a guess based on the information you posted.