Forum Replies Created

Viewing 13 replies - 31 through 43 (of 43 total)
  • Thread Starter korynorthrop

    (@korynorthrop)

    Thanks for your reply @bcworkz. I have everything updated and have installed the twentynineteen theme and disabled all other plugins, but can only get this filter to work if I call it like so instead of calling a custom function that I declare:

    add_filter( 'wp_insert_post_data', function ( $data, $postarr ) {
       // do stuff
       return $data;
    }, 10, 2 );

    But, another thing I’m scratching my head about is that I’m seeing this hook firing three times when I update a post. If I write something to the error_log (e.g. error_log( 'post saved', 0 ); I’ll see it three times in the log file, a few seconds apart. Any ideas on what’s happening there?

    • This reply was modified 5 years, 9 months ago by korynorthrop.

    I see that, I was asking/suggesting that you get rid of the setAjaxCallback() function and have your ‘wp_ajax_accepted’ and ‘wp_ajax_nopriv_accepted’ filters on their own like so:

    
    add_action('wp_ajax_accepted', 'accepted');
    add_action('wp_ajax_nopriv_accepted', 'accepted');
    
    function accepted() {
    
        die('test');
        echo 'LOLALLES';
        global $wpdb;
        $whatever = intval( $_POST['whatever'] );
        $whatever += 10;
        echo $whatever;
        wp_die('0 ', 400);
    
        echo '<script>
            alert("jhwgvbht ij")
        </script>';
        wp_die();
    }
    
    isset($_COOKIE['cookieBar']) or setCookieBar();
    
    function setCookieBar() {
        if ( !is_admin() ) {
    
            add_action( 'wp_enqueue_scripts', 'enqueue_script_custom' );
    
            function enqueue_script_custom() {
                wp_enqueue_style('CookieBarStyle', plugin_dir_url(__FILE__) . 'css/styles.css');
                wp_enqueue_script('ajax-script', plugins_url('/js/my_query.js', __FILE__), array('jquery'));
                wp_localize_script('ajax-script', 'ajax_object',
                    array('ajaxurl2' => 'https://wordpressjip.jmulder.dt2/wp-admin/admin-ajax.php', 'we_value' => 1234));
    
                wp_print_scripts('ajax-script');
            }
            ?>
    
            <div class="cookieBar" id="cookieBar" style="display: block">
                <p align="center"></p>
    
                <button id="submitCookies" class="submitCookies" name="accepted">Accepteer</button>
            </div>
        <?php
        }
    }
    

    Have you tried taking the AJAX hooks out of the setAjaxCallbacks() function in your main plugin file?

    
    // no longer inside the setAjaxCallback() function that was triggered on 'init'
    add_action('wp_ajax_accepted', 'accepted');
    add_action('wp_ajax_nopriv_accepted', 'accepted');
    
    function accepted(){
        // rest of code
    }
    
    Thread Starter korynorthrop

    (@korynorthrop)

    Thank you @laszloszalvak. I didn’t realize I could just use the normal login_message filter to replace the one set by Nextend Social Login. That is exactly what I needed.

    Thread Starter korynorthrop

    (@korynorthrop)

    Thanks @laszloszalvak for your quick reply. The “Prevent external redirect overrides” option did not solve the issue, but I looked into some of my code for other redirects. I found the culprit, I had setup a redirect using the ‘profile_update’ WordPress hook to send normal Subscriber accounts back to the home page whenever they edit their profiles. When I removed that hook things worked properly.

    It’s not super important for us to redirect users to the homepage after they edit their profiles, but can you think of a way to accomplish both? Say, only redirect them if the profile update wasn’t related to the Nextend Social Login registration event?

    Thread Starter korynorthrop

    (@korynorthrop)

    On the live site (https://classroom.therefugeecenter.org/login), once you click on a social login button, Google+ for instance, then choose the Google account you want to use, the popup closes, the page loading spinner starts spinning in the browser tab, and then the login page just reloads. At this point, the user is neither logged in nor taken to the intended “My Courses” page all of which happens perfectly well on the staging site (https://clrefugeecent.dev.onpressidium.com/?login)

    Pressidium support said that they tried excluding the entire directory from their cache ( “^/wp-content/plugins/super-socializer”), but had no success.

    Here is a video of the staging site working properly.

    Here is a video of the live site not working as hoped.

    • This reply was modified 6 years, 9 months ago by korynorthrop.
    Thread Starter korynorthrop

    (@korynorthrop)

    Excluding all of those files from the cache hasn’t solved the problem. Are there any other files that would be causing the issue? Do you have any other thoughts on what to try? I can give you the links for the live site (not working) and the staging site (is working) if that’s helpful.

    Thank you kindly!

    @backpackingseries what did your web host do to help you fix this issue? I am running into the same thing myself.

    Thanks,
    Kory

    Thread Starter korynorthrop

    (@korynorthrop)

    Thanks @iandunn! Plugin is exactly what I’m looking for. However, I did run into a slight issue after I installed it. Things work as desired for the non-administrators, they just log in as normal without the authenticator field coming up, but for the administrators I have a conflict once the authentication code is submitted. I built a custom login page and workflow for the site. I have a filter setup that fires during the authenticate filter as well, so when I submit the code I get redirected to our custom login page with the error message that normally comes up for a user when they try to login without filling in their password. Any thoughts on a way to work around this?

    Thread Starter korynorthrop

    (@korynorthrop)

    That works great. Thanks again for your quick support.

    Thread Starter korynorthrop

    (@korynorthrop)

    Thanks for your reply. My client just told me that they aren’t actually accepting partial payments, they just wanted to include Amount Paid and Balance Due on the invoice to reflect whether the Order was paid or not. Your response is useful to know going forward, though. I appreciate it.

    I needed to accomplish the same thing and finally got the Contact Form 7 results to be converted to a PDF.

    add_action('wpcf7_before_send_mail', 'wpcf7_update_email_body');
    function wpcf7_update_email_body($contact_form) {
    
    $submission = WPCF7_Submission::get_instance();
    if ( $submission ) {
    /* DEFINE CONSTANT AND GET FPDF CLASSES */
    define ('FPDF_PATH',get_template_directory().'/fpdf/'); // MAKE SURE THIS POINTS TO THE DIRECTORY IN YOUR THEME FOLDER THAT HAS FPDF.PHP
    require(FPDF_PATH.'fpdf.php');
    
    $posted_data = $submission->get_posted_data();
    // SAVE FORM FIELD DATA AS VARIABLES
    $name = $posted_data["your-name"];
    $email = $posted_data["your-email"];
    $subject = $posted_data["your-subject"];
    $message = $posted_data["your-message"];
    
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    $pdf->Write(5,$name . "\n\n" . $email . "\n\n" . $subject . "\n\n" . $message);
    $pdf->Output(FPDF_PATH.'test.pdf', 'F'); // OUTPUT THE NEW PDF INTO THE SAME DIRECTORY DEFINED ABOVE
    
    }
    }
    
    add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );
    function mycustom_wpcf7_mail_components($components){
    if (empty($components['attachments'])) {
    $components['attachments'] = array(FPDF_PATH .'test.pdf'); // ATTACH THE NEW PDF THAT WAS SAVED ABOVE
    }
    return $components;
    }

    I needed to accomplish the same thing and finally got the Contact Form 7 results to be converted to a PDF.

    add_action('wpcf7_before_send_mail', 'wpcf7_update_email_body');
    function wpcf7_update_email_body($contact_form) {
    
    $submission = WPCF7_Submission::get_instance();
    if ( $submission ) {
    /* DEFINE CONSTANT AND GET FPDF CLASSES */
    define ('FPDF_PATH',get_template_directory().'/fpdf/'); // MAKE SURE THIS POINTS TO THE DIRECTORY IN YOUR THEME FOLDER THAT HAS FPDF.PHP
    require(FPDF_PATH.'fpdf.php');
    
    $posted_data = $submission->get_posted_data();
    // SAVE FORM FIELD DATA AS VARIABLES
    $name = $posted_data["your-name"];
    $email = $posted_data["your-email"];
    $subject = $posted_data["your-subject"];
    $message = $posted_data["your-message"];
    
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    $pdf->Write(5,$name . "\n\n" . $email . "\n\n" . $subject . "\n\n" . $message);
    $pdf->Output(FPDF_PATH.'test.pdf', 'F'); // OUTPUT THE NEW PDF INTO THE SAME DIRECTORY DEFINED ABOVE
    
    }
    }
    
    add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );
    function mycustom_wpcf7_mail_components($components){
    if (empty($components['attachments'])) {
    $components['attachments'] = array(FPDF_PATH .'test.pdf'); // ATTACH THE NEW PDF THAT WAS SAVED ABOVE
    }
    return $components;
    }
Viewing 13 replies - 31 through 43 (of 43 total)