Gravity Forms Error - wordpress

I keep trying to setup a notification when a form is submitted but I'm not getting the emails. When I go back in to edit the notification, it is not there. It's like it is not saving that. Then I noticed this on the notifications page: function WP_List_Table::get_columns() must be over-ridden in a sub-class. Any idea what that means?
Note: It is saving the submissions in the entries area of the plugin.

There is a simple fix for this without upgrading Gravity Forms, but you'd have to edit a plugin file for Gravity Forms.
in notification.php, in the class
GFNotificationTable extends WP_List_Table {
...
Add this method:
function get_columns() {
$columns = array(
'name' => 'Name',
'subject' => 'Subject'
);
return $columns;
}
The same solution can be applied to any plugin where you're seeing this problem. The columns array just needs to match the names set as $this->_column_headers.

Adding to the previous answer, to fully fix the problem you'll need to also place that same function:
function get_columns() {
$columns = array(
'name' => 'Name',
'subject' => 'Subject'
);
return $columns;
}
In the GF form_settings.php file under the class GFConfirmationTable extends WP_List_Table.
The first fixes the Notifications error and this fixes the Confirmations error.

I figured it out. Once I put the license key into the settings, I was able to download the update. Installed and the error went away.

You also have to add it to:
class GFAddOnFeedsTable extends WP_List_Table of file "class-gf-feed-addon.php" in includes/addons folder in order for add ons to work.
function get_columns() {
$columns = array(
'name' => 'Name',
'subject' => 'Subject'
);
return $columns;
}

You have to try this code inside wp-admin/includes/class-wp-list-table.php
Copy and paste this code inside the function public function get_columns() at line 872.
$columns = array(
'name' => 'Name',
'subject' => 'Subject'
);
return $columns;

I have tried this code snippet and it worked!
function get_columns() {
$columns = array(
'name' => 'Name',
'subject' => 'Subject'
);
return $columns;
}

Related

Drupal 8 Twig - custom block - two twig templates working third is not?

I have a custom module modero_kbo that creates a custom block.
I need to display this block differently depending on where it is placed on my page.
I have this function in my modero_kbo.module:
function modero_kbo_theme() {
return array(
'modero_kbo_vat' => array(
'variables' => array(
'form' => NULL
)
),
'modero_kbo__landing_page' => array(
'variables' => array(
'form' => NULL
)
),
'modero_kbo__landing_page__modero_kbo_form_2.html.twig' => array(
'variables' => array(
'form' => NULL
)
),
);
}
And this in my custom theme .theme file:
/**
* Implements hook_theme_suggestions_HOOK_alter() for modero_kbo.html.twig.
*/
function moderosolid_theme_suggestions_modero_kbo_vat_alter(array &$suggestions, array $variables) {
if($node = \Drupal::routeMatch()->getParameter('node')){
$suggestions[] = 'modero_kbo__' . $node->bundle();
$suggestions[] = 'modero_kbo__' . $node->bundle() . '__' . $variables['form']['#attributes']['data-drupal-selector'];
}
}
All 3 template suggestions are showing up in my html source on the page.
The first two actually work, the third one is not working.
I've tripple checked all the file names and spelling.
I have 3 different template files, the first two are working, the third one is showing in the suggestions list, but is not used for some reason?
modero-kbo-vat.html.twig
modero-kbo--landing-page.html.twig
modero-kbo--landing-page--modero-kbo-form-2.html.twig
One error we found here is that I should only be using the first array in the modero_kbo_theme() function.
The moderosolid_theme_suggestions_modero_kbo_vat_alter alters that theme.
We could not figure out why the 3rd hook was not working, we suspect that the form variables might not be available at some point in the process.
I solved this by copying the block and creating a new block with a custom template.

Change formatted address order no longer working

Something appears to have changed in the new version of WooCommerce, this snippet to change the order of the items in a formatted address used to work fine....
add_filter( 'woocommerce_order_formatted_billing_address' , 'woo_custom_order_formatted_billing_address' );
/**
* woo_custom_order_formatted_billing_address
*
* #access public
* #since 1.0
* #return void
*/
function woo_custom_order_formatted_billing_address() {
$address = array(
'first_name' => $this->billing_first_name,
'last_name' => $this->billing_last_name,
'company' => $this->billing_company,
'address_1' => $this->billing_address_1,
'address_2' => $this->billing_address_2,
'city' => $this->billing_city,
'state' => $this->billing_state,
'postcode' => $this->billing_postcode,
'country' => $this->billing_country
);
return $address;
}
But now it returns the following error...
Fatal error: Using $this when not in object context in
Can anyone point me in the right direction of either what is going wrong or an alternative way of achieving it?
I'm seeing this example on the internet, but I don't know if it ever worked. First of because in 'woocommerce_order_formatted_billing_address' filter, that is applied in class-wc-order.php file, two arguments are provided, $address ARRAY, and a reference to current WC_Order OBJECT. But your definition of the filter function does not provide any arguments. Second, error that you receive describes the problem very accurately, pseudo-variable $this is available from within an object context, but your global function is not part of any object.
Enough with technicalities, the definition should look like this:
add_filter( 'woocommerce_order_formatted_billing_address' , 'woo_custom_order_formatted_billing_address', 10, 2 );
function woo_custom_order_formatted_billing_address( $address, $wc_order ) {
// make the changes to $address array here
// use for example, $wc_order->billing_first_name, instead of $this->billing_first_name
return $address;
}
#Eolis' answer doens't work for me, because Woocommerce applies WC()->countries->get_formatted_address( $address ) and this functions erases my new fields added to array on add_filter, so my solution is add field to previous field (first_name):
add_filter('woocommerce_order_formatted_billing_address', 'my_order_formatted_billing_address', 10, 2);
function my_order_formatted_billing_address($address, $wc_order) {
$billing_last_name_2 = get_post_meta( $wc_order->id, '_billing_last_name_2', true );
$address = array(
'postcode' => $wc_order->billing_postcode,
'last_name' => $wc_order->billing_last_name,
//\n force break line
'first_name' => $wc_order->billing_first_name . "\n" . $billing_last_name_2,
'address_1' => $wc_order->billing_address_1,
'address_2' => $wc_order->billing_address_2,
'city' => $wc_order->billing_city,
'state' => $wc_order->billing_state,
'country' => $wc_order->billing_country
);
return $address;
}

redirection on MYMODULE_user_register_form_alter

ive been searching a lot and found a lot of post also but cant still make my code works. i dont really know the problem anymore, it is so hard to debug.
so i have this code module send_xml.module
i used the hook_form_FORMID_alter, it was like
function send_xml_form_user_register_form_alter(&$form, &$form_state) {
$form['#submit'][] = 'send_xml_submit_function';
}
function send_xml_submit_function($form, &$form_state){
$email = $form_state['values']['mail'];
$password = $form_state['values']['pass'];
unset($_REQUEST['destination']);
unset($form['#redirect']);
$form_state['redirect'] = array(
'myurl',
array(
'query' => array(
'email' => $email,
'password' => $password,
),
),
);
}
i want this to redirect to an external link with the values from the regsitration form... but i can't get it to work... its my 3rd day now at is giving me a lot of pain really...
please help anyone please... it will be a big help. thank you very much! :)
In your submit method, give url instead of array using url() function to set redirect value. Currently you are giving array in $form_state['redirect]. Try following:
$form_state['redirect'] = url('myurl', array(
'query' => array (
'email' => $email,
'password' => $password)
)
);

Passing Form to Template using RenderWith method

I am using the Silverstripe comments module by Willr along with an implementation of DataObjects as Pages.
The comments module allows you to attach comments to Data Objects - which I have done. The problem I am having is that when I attempt to pass through customfields from the Datobject to a template using renderwith, the CommentsForm that gets passed renders the form, but does not associate any comments made through the passed form with the DataObject.
Here is my action and renderWith method on my PostsPageHolder:
public function view($request) {
$segment = $request->param('ID');
if ($obj = Post::get()->filter('URLSegment', $segment)->First()) :
switch ($obj->Type) {
case 'News-Post' :
return $this->renderWith(
array('PostsPage_view_news', 'Page'),
array(
'Object' => $obj,
'Type' => $obj->Type,
'Title' => $obj->Title,
'Entry' => $obj->Entry,
'CommentsForm' => $obj->CommentsForm
)
);
break;
...
}
Does anyone know how I can pass through the form using the RenderWith() array?
try customise(array) as shown here https://docs.silverstripe.org/en/3/tutorials/site_search/#showing-the-results
return $this->customise(array(
'Object' => $obj,
'Type' => $obj->Type,
'Title' => $obj->Title,
'Entry' => $obj->Entry,
'CommentsForm' => $obj->CommentsForm
))->renderWith(
array('PostsPage_view_news', 'Page')
);

hook_load/hook_view not called

I have a module with four node types declared. My problem is, hook_load, hook_view is never called. I used drupal_set_message to find out if certain hook is being called. And I found out hook_load, hook_view isn't. Just to give you clear picture, here's my structure of hook_load
HERE'S UPDATED ONE
function mymodule_node_info(){
return array(
'nodetype1' => array(
'name' => t('nodetype1'),
'module' => 'mymodule_nodetype1',
'description' => t('....'),
'has_title' => TRUE,
'title_label' => t('Title'),
'has_body' => TRUE,
'body_label' => t('Body'),
),
'nodetype2' => array(
......
'module' => 'mymodule_nodetype2',
......
),
'nodetype3' => array(
......
'module' => 'mymodule_nodetype3',
......
),
'nodetype4' => array(
......
'module' => 'mymodule_nodetype4',
.......
),
);
}
function mymodule_nodetype1_load($node){
$result = db_query('SELECT * from {nodetype1table} WHERE vid = %d'
$node->vid
);
drupal_set_message("hook_load is provoked.","status");
return db_fetch_object($result);
}
I don't know why it is not called. I wrote this code base on drupal module writing book and follow the instructions. I've tried sample code from that book and it works ok. Only my code isn't working. Probably because of multiple node types in one module. Any help would be highly appreciated.
Your code doesn't work because hook_load() and hook_view() aren't module hooks: they're node hooks. The invocation is based off of content type names, not module names.
So, first you need to have declared your content types using hook_node_info():
function mymodule_node_info() {
$items = array();
$items['nodetype1'] = array(
'name' => t('Node Type 2'),
'module' => 'mymodule_nodetype1',
'description' => t("Nodetype 1 description"),
);
$items['nodetype2'] = array(
'name' => t('Node Type 2'),
'module' => 'mymodule_nodetype2',
'description' => t("Nodetype 2 description"),
);
$items['nodetype3'] = array(
'name' => t('Node Type 2'),
'module' => 'mymodule_nodetype3',
'description' => t("Nodetype 3 description"),
);
return $items;
}
Then, you need to use the name of the module you specified for each content type declared in hook_node_info() for your node hooks. That is, mymodule_nodetype1_load(), mymodule_nodetype2_view(), etc.
Edit
If you're trying to have a non-node based module fire when a node is viewed or loaded, you need to use hook_nodeapi():
function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'view':
mymodule_view_function($node);
break;
case 'load':
mymodule_load_function($node);
break;
}
}
Replace mymodule_load_function() and mymodule_load_function() with your own custom functions that are designed to act on the $node object.
Edit 2
Besides the syntax error in your hook_load() implementations, there's a piece of your code outside of what you're providing that's preventing the correct invocation. The following code works (if you create a nodetype1 node, the message "mymodule_nodetype1_load invoked" appears on the node): perhaps you can compare your entire code to see what you're missing.
function mymodule_node_info() {
return array(
'mymodule_nodetype1' => array(
'name' => t('nodetype1'),
'module' => 'mymodule_nodetype1',
'description' => t('....'),
'has_title' => TRUE,
'title_label' => t('Title'),
'has_body' => TRUE,
'body_label' => t('Body'),
),
'mymodule_nodetype2' => array(
'name' => t('nodetype2'),
'module' => 'mymodule_nodetype2',
'description' => t('....'),
'has_title' => TRUE,
'title_label' => t('Title'),
'has_body' => TRUE,
'body_label' => t('Body'),
),
);
}
function mymodule_nodetype1_form(&$node, $form_state) {
// nodetype1 form elements go here
return $form;
}
function mymodule_nodetype2_form(&$node, $form_state) {
// nodetype2 form elements go here
return $form;
}
function mymodule_nodetype1_load($node) {
$additions = new stdClass();
drupal_set_message('mymodule_nodetype1_load invoked');
return $additions;
}
function mymodule_nodetype2_load($node) {
$additions = new stdClass();
drupal_set_message('mymodule_nodetype2_load invoked');
return $additions;
}
If you're not reseting your environment after changes to your module, you might be running into caching issues. You should test your code in a sandbox environment that can be reset to a clean Drupal installation to ensure you're not focusing on old cruft from previous, incorrect node implementations.
Additionally, you should only be using hook_nodeapi() if you are trying to act on content types that are not defined by your module. Your content types should be using the node hooks (hook_load(), hook_view(), etc.).
Finally, it may be the case that you're using the wrong hooks because you're expecting them to fire in places they are not designed to. If you've gone through everything above, please update your post with the functionality you're expecting to achieve and where you expect the hook to fire.
I found the culprit why your code doesn't work. It's because I was using the test data created by the old codes. In my old codes, because of node declaration inside hook_node_info uses the same module value, I could only create one hook_form implementation and use "switch" statement to return appropriate form. Just to give you clear picture of my old codes-
function mymodule_node_info(){
return array(
'nodetype1' => array(
.....
'module' => 'mymodule',
.....
),
'nodetype2' => array(
......
'module' => 'mymodule',
......
),
.......
);
}
function mymodule_form(&$node, $form_state){
switch($node->type){
case 'nodetype1':
return nodetype1_form();
break;
case 'nodetype2':
return nodetype2_form();
break;
.....
}
}
When I created new data after I made those changes you have provided, hook_load is called. It works! I've tested several times(testing with old data created by previous code and testing with new data created after those changes) to make sure if that's the root cause and, I got the same result.I think drupal store form_id or module entry value of node declaration along with data and determine the hook_load call. That's probably the reason why it doesn't think it's a data of this node and thus hook_load isn't invoked.
And Thank you so much for your help.

Resources