Ryan
Forum Replies Created
-
Forum: Plugins
In reply to: [wpForo Forum] Lot’s of warnings in error logsOk. How do I fix that then?
Forum: Plugins
In reply to: [wpForo Forum] Lot’s of warnings in error logsAlso, I should mention that I originally migrated that forum from bbpress with the plugin for that. Maybe that would be relevant in some way.
Forum: Plugins
In reply to: [wpForo Forum] Lot’s of warnings in error logsBrowsing recent posts menu still causing this:
[13-Jul-2018 15:57:40 UTC] PHP Warning: Illegal string offset 'created' in /home/example/example.com/wp-content/plugins/wpforo/wpf-themes/classic/recent.php on line 93wp-cli doesn’t seem to cause those notices anymore, at least with the site I tested.
Forum: Plugins
In reply to: [wpForo Forum] Lot’s of warnings in error logsThe errors are definitely caused by plugins and seemingly wpForo but perhaps it’s conflicting with the caching plugin or some other plugin in the case of the session_start warning. Based on my research it seems like you may possibly be are using session_start in the wrong spot. It might have to go behind an action such as wp_loaded or simply be replaced with another, more secure method as can be seen in the links I’ll put below. I may have resolved the session_start warning by removing a conflicting plugin because I haven’t seen that one for a few days now.
The errors only seem to occur on sites with wpForo on them. So perhaps it’s conflicting with something or perhaps wpForo just shouldn’t be doing what it’s doing. I’ll have to do some more testing to find out what for sure but perhaps these links will be useful to you in the meantime. It might seem like a lot but it also seems very important for security.
https://wordpress.stackexchange.com/questions/237023/how-should-you-hook-a-session-start-when-authoring-a-plugin
https://wordpress.stackexchange.com/questions/167585/using-sessions-to-filter-posts-bad-thing/168089#168089
https://pressjitsu.com/blog/wordpress-sessions-performance/
https://wpengine.com/support/cookies-and-php-sessions/Also, those aren’t the only errors I saw in logs on various sites with wpForo on them but I couldn’t find anymore errors at that time as I had recently cleared the error logs. I’ve since found some more now though that I’ll post for you.
Here are some others when running wp-cli on the site:
Notice: Undefined index: SERVER_PORT in /home/example/example.com/wp-content/plugins/wpforo/wpf-includes/functions.php on line 257 Notice: Undefined index: HTTP_HOST in /home/example/example.com/wp-content/plugins/wpforo/wpf-includes/functions.php on line 258Here is another one I get when browsing the recent posts menu:
[26-Jun-2018 09:29:03 UTC] PHP Warning: Illegal string offset 'created' in /home/example/example.com/wp-content/plugins/wpforo/wpf-themes/classic/recent.php on line 93I may have more for you eventually, I recall having more undefined index errors before but I don’t know where I saw them.
This is on PHP 7.2.5.
Thanks!
Yeah I thought about doing a cron as well but ended up doing it this way instead.
I think WP messes with the formatting so here it is as a gist: https://gist.github.com/ty2u/36fbc912d7dd886e5057ba6911cd794f
Sure, let’s see if I can get it to work properly. Although you will have to modify it to match your form fields. There are a number of custom fields added in here for their particular form and I didn’t bother adding those dynamically yet. I’m not sure if that’s even possible but I wanted the email formatted a specific way too.
Anyway, this adds a shortcode to add into the content of the page indicated in the “After submit… Go to page” setting in the form settings. The shortcode has a “to” parameter for an email address to send the notifications to and defaults to the admin email in the WP settings.
Example usage:
[send-mp-notification to="example@example.com"]In my case I created a new plugin to put this code into. So you should just have to make a new file at wp-content/plugins/mpnotifications.php and put this code into it after adjusting the fields accordingly.
<?php /* Plugin Name: MP Notifications Plugin URI: https://servercode.ca/ Description: Provides notifications for MailPoet form submissions. Author: Ryan Rhode Version: 1.0 Author URI: https://servercode.ca/ */ // TODO: dynamic custom fields if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Shortcode to send notifications to admins on new subscribers. * * Note: Field names are cf_# where # is the id column in wp_mailpoet_custom_fields * * @param $atts */ function custom_notify_of_new_subscribers( $atts ) { global $wpdb; $a = shortcode_atts( array( 'to' => get_bloginfo( 'admin_email' ) ), $atts ); $subscribers = $wpdb->get_results( 'SELECT * FROM <code>wp_mailpoet_subscribers</code> WHERE <code>updated_at</code> > NOW() - INTERVAL 10 SECOND', ARRAY_A ); foreach ( $subscribers as $subscriber ) { $data = array(); if ( isset( $subscriber['unconfirmed_data'] ) && ! empty( $subscriber['unconfirmed_data'] ) ) { // updated existing subscriber // {"email":"example@example.com","first_name":"John","last_name":"Smith","cf_1":"12345","cf_2":"123-123-1234","cf_7":"1","cf_4":"Some additional comments"} $data = json_decode( $subscriber['unconfirmed_data'], true ); } else { // new subscriber $data['first_name'] = $subscriber['first_name']; $data['last_name'] = $subscriber['last_name']; $data['email'] = $subscriber['email']; $fields = $wpdb->get_results( 'SELECT custom_field_id,value FROM <code>wp_mailpoet_subscriber_custom_field</code> WHERE <code>subscriber_id</code>=' . intval( $subscriber['id'] ), ARRAY_A ); foreach ( $fields as $field ) { if ( $field['custom_field_id'] == 1 ) { // zip $data['cf_1'] = $field['value']; } if ( $field['custom_field_id'] == 2 ) { // phone $data['cf_2'] = $field['value']; } if ( $field['custom_field_id'] == 4 ) { // additional comments $data['cf_4'] = $field['value']; } if ( $field['custom_field_id'] == 6 ) { // windows $data['cf_6'] = $field['value']; } if ( $field['custom_field_id'] == 7 ) { // doors $data['cf_7'] = $field['value']; } if ( $field['custom_field_id'] == 8 ) { // siding $data['cf_8'] = $field['value']; } if ( $field['custom_field_id'] == 9 ) { // gutters $data['cf_9'] = $field['value']; } if ( $field['custom_field_id'] == 10 ) { // roofs $data['cf_10'] = $field['value']; } } } $subject = "New form submission on " . sanitize_text_field( html_entity_decode( get_bloginfo( 'name' ) ) ); $message = ""; $message .= "First Name: " . sanitize_text_field( $data['first_name'] ) . "\r\n"; $message .= "Last Name: " . sanitize_text_field( $data['last_name'] ) . "\r\n"; $message .= "Email: " . sanitize_email( $data['email'] ) . "\r\n"; if ( isset( $data['cf_1'] ) ) { $message .= "Zip: " . sanitize_text_field( $data['cf_1'] ) . "\r\n"; } if ( isset( $data['cf_2'] ) ) { $message .= "Phone: " . sanitize_text_field( $data['cf_2'] ) . "\r\n"; } $interests = array(); if ( isset( $data['cf_6'] ) && $data['cf_6'] == 1 ) { $interests[] = "Windows"; } if ( isset( $data['cf_7'] ) && $data['cf_7'] == 1 ) { $interests[] = "Doors"; } if ( isset( $data['cf_8'] ) && $data['cf_8'] == 1 ) { $interests[] = "Siding"; } if ( isset( $data['cf_9'] ) && $data['cf_9'] == 1 ) { $interests[] = "Gutters"; } if ( isset( $data['cf_10'] ) && $data['cf_10'] == 1 ) { $interests[] = "Roofs"; } if ( ! empty( $interests ) ) { $message .= "Interests: " . implode( ',', $interests ) . "\r\n"; } if ( isset( $data['cf_4'] ) ) { $message .= "Additional Comments: " . sanitize_text_field( $data['cf_4'] ) . "\r\n"; } wp_mail( sanitize_email( $a['to'] ), $subject, $message ); } } add_shortcode( 'send-mp-notification', 'custom_notify_of_new_subscribers' );- This reply was modified 8 years, 5 months ago by Ryan.
Yes I sure can. I have a whole bunch of other things and maybe even some that were attached to existing sections but only this one seemed to be causing errors when I added it, even though it did still show up as an option and seemed to work.
Something_Kirki::add_field( 'something_theme', array( 'type' => 'radio-buttonset', 'settings' => 'display_header_text', 'label' => __( 'Display Site Title', 'something' ), 'section' => 'title_tagline', 'default' => 'block', 'priority' => 10, 'choices' => array( 'block' => esc_attr__( 'Show', 'something' ), 'none' => esc_attr__( 'Hide', 'something' ), ), 'output' => array( array( 'element' => '.site-title', 'property' => 'display', ), ), ) );This similar one does not cause an error:
Something_Kirki::add_field( 'something_theme', array( 'type' => 'radio-buttonset', 'settings' => 'display_tagline', 'label' => __( 'Display Tagline', 'something' ), 'section' => 'title_tagline', 'default' => 'block', 'priority' => 11, 'choices' => array( 'block' => esc_attr__( 'Show', 'something' ), 'none' => esc_attr__( 'Hide', 'something' ), ), 'output' => array( array( 'element' => '.site-description', 'property' => 'display', ), ), ) );Hi there,
I had this same issue. For me it was due to the fact that I had added custom controls to the display_header_text settings. This was causing a javascript error in Kirki which causes the ready event to not fire and therefore the button remains hidden. So it would seem that adding new fields to the display_header_text settings doesn’t seem to work, maybe adding custom fields to other existing sections causes similar issues but I haven’t tried.
The Publish button is still on the page but is set to visibility:hidden and can be shown through the inspector by removing that style and works fine.
My error was:
TypeError: control.elements[0] is undefined
customize-controls.js:9038:4So perhaps you have added some custom controls to existing sections in a similar way which is causing a similar error?
Having the same issue as this. Noticed this error in the logs:
[Mon Dec 11 09:40:31.063035 2017] [fcgid:warn] [pid 25019] [client xx.xx.xx.xx:51905] mod_fcgid: stderr: PHP Warning: filesize(): stat failed for /home/example/public_html/wp-content/uploads/wp-statistics/GeoLite2-Country.mmdb in /home/example/public_html/wp-content/plugins/wp-statistics/includes/classes/class-wp-statistics-schedule.php on line 199, referer: https://example.com/wp-cron.php?doing_wp_cron=1513003230.8876769542694091796875
Checked the /home/example/public_html/wp-content/uploads/wp-statistics/ folder and found it didn’t exist. Created it. Tried to to initialize the GeoIP download again (Settings > External > Check Download GeoIP Database and Update) but didn’t seem to download it and didn’t give an error anymore. Still no countries working and no GeoLite2-Country.mmdb in that folder.
Forum: Plugins
In reply to: [.TUBE Video Curator] Some feature requestsSorry for the delayed response. I’ve been busy with other sites for clients and haven’t had a chance to work on this one. I put the code you posted in but haven’t gotten it to work properly yet. I’ll try the latest one you posted today and see if I can make it work. Ideally though it would be something I could change from within WP rather than having to edit the code each time but maybe I can code something up for that.
I had to have this so I wrote a way to do it but it may not be ideal for everyone and isn’t necessarily quite finished yet so I can’t include any code for it. I’m sure they will add this feature eventually in a nicer way.
I actually made two ways to do it, the first way I no longer have or am using but it would attempted to detect the URL parameters in the confirmation link and then get the subscriber data from the users by using the MailPoet Export->getSubscribers function and keep a transient cache of subscribers that the admin have already been sent a notification for. Then it would simply use the wp_mail function to send an email.
However for the client this was no good because they required some forms to be submitted multiple times, as well as subscribe them to multiple lists. So in the end I created a shortcode to add into the content of the page indicated in the “After submit… Go to page” setting in the form settings. The shortcode has an email parameter to send the notifications to. I made it send the notifications by querying the database directly for subscribers who have the updated_at field modified within the last 10 seconds which should get the last subscriber who just submitted the form. I then take the unconfirmed_data field and parse the JSON out and get the custom fields data from here. I couldn’t find it anywhere else but glad it’s here. It’s only there until they click the confirm link though. It’s quite hacky but it actually works. The only issue might be if multiple people are submitting the form at the same time within 10 seconds it may cause duplicate notifications but I guess that’s fine and quite likely won’t happen anyway in this case.
Anyway, maybe that will help someone.
oh…this is reason to use MailPoet 2 instead of 3
Except that MailPoet 2 is likely going to stop getting updates eventually and therefore likely get pulled from wordpress.org at some point.
If you aren’t going to add this feature or even if you are, could you please describe a way to intercept the form submission data so that I might be able to use the wp_mail function to send that data to someone?
I’ve tried hooking into the admin_post_nopriv_mailpoet_subscription_form and admin_post_mailpoet_subscription_form actions as well as the wp_redirect filter to no avail. I’m not sure why but I can’t get any of the form data at any point in the request no matter where I try to do it, even if it’s right in the root file of a plugin or in the functions.php of the theme, there is no POST, GET or REQUEST data from that form going through due to the request going to the admin-post file and somehow that is not giving me anything in the hooks I’ve tried which I’m not understanding.
The only thing I found I can do is add a shortcode that goes into the “After submit… Go to page” and use the MailPoet Export getSubscribers function to get all the subscribers and loop through them keeping a transient cache of the ones I’ve sent notifications for. However this isn’t ideal nor will it work in this case because the form can be submitted multiple times on this site I’m working on and has to send a notification each time with the submitted data.
Any ideas? Please add more hooks everywhere.
Forum: Plugins
In reply to: [.TUBE Video Curator] Some feature requestsOK, awesome! I will test that out later. I think I might understand how it should work. Thank you =)
Forum: Plugins
In reply to: [External Media] Frontend supportIt happens when logged in, in my case as an admin when the media select box shows. When not logged in it just lets you upload a file but when logged in it displays the same screen as when trying to upload from the admin area. On the Upload Files tab the Import from Dropbox button doesn’t do anything. I believe this isn’t due to a conflict and there are no errors. I believe it’s because the scripts are not enqueued for the frontend but only the admin.
Forum: Reviews
In reply to: [Shortn.It] Great little plugin…Still works on 4.7.4 as well for me.
https works fine too for me. I had to add my other domain to my SSL certificate for it to work.