How to integrate the Ninja Popups plugin with the Subscribe by Email plugin

I am using the Ninja Popups plugin from CodeCanyon on my clients website.

I am also using the Subscribe by Email plugin from WPMU.

Now, I want to integrate the Ninja Popups plugin with Subscribe by Email plugin, so that whenever a user enters an email in the Ninja popup window, then I will be added directly to the database with subscribers.

The Ninja Popups plugin has a Settings page where you can specify where the email is send to. There is a an option named "HTML Form", I believe this is the option that should be used but I am not quite sure how.

Please see attached image!

I would appreciate an help I can get on this issue!

Thanks a lot!
Sincerely,
Mika

  • Tyler Postle
    • CGO

    Hey Mika,

    Hope you're doing well today and thanks for your question!

    It would take further customization to be able to integrate the 2 plugins in that manner; however, in the past many members have used this plugin: https://wordpress.org/plugins/widgets-on-pages/

    Which allows you to place the subscribe by email widget directly into the pop up :slight_smile: assuming the pop ups are custom post types similar to ours in PopUp Pro.

    Let us know if that does the trick. If not, we will look into some alternatives with you!

    Look forward to hearing back.

    All the best,
    Tyler

  • Mika
    • The Bug Hunter

    Hey Tayler.

    Thanks for your reply! I hope you are doing good as well today!

    I have actually tried to add the shortcode into WPMU's PopUp Pro plugin and it worked, however, the styling was really not that great.

    Ninja Popups plugin does have some really nice templates out of the box which I would like to use if possible :slight_smile:

    Sincerely,
    Mika

  • Mika
    • The Bug Hunter

    Hey Michelle,

    Yes, I actually did this before I wrote this thread. However, I would like to use the Ninja Pop Up predefined design.

    Is there anyone that would be able to help me get the two plugins working together although it might be some customization? :slight_smile:

    Sincerely,
    Mika

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hi there, Mika!

    I just checked to see if we have access to Ninja Pop Up, and at this point we do not, and I don't have it in my personal collection, so I'm not able to test it.

    I can add a feedback flag for the Dev, Ingacio, and we can see if he might have some insights into how to make the Subscribe by Email shortcode work with Ninja Pop Ups.

    Thanks for your patience!

  • Mika
    • The Bug Hunter

    Hey Ignacio.

    I've just received an email back from my client where this issue is at hand. They would like an email to be send instead (which is easy to setup), so I guess we can conclude this project as it is no longer relevant.

    However, it would be nice to know how it is actually possible to accomplish as I would be a great feature to have in the toolbelt for future projects :slight_smile:

    Sincerely,
    Mika

  • Mika
    • The Bug Hunter

    Hey Ignacio.

    I had a further conversation with my client and she would like to do the integrate the Ninja Popups plugin with Subscribe by Email plugin, so that whenever a user enters an email in the Ninja popup window, it will be added directly to the database with subscribers. However, a confirmation email should be send out as well to the subscriber.

    Looking forward hearing back from you on this one.

    Sincerely,
    Mika

  • Ignacio
    • HummingBird

    I think that plugin is a premium one, isn't it?

    The idea would be to hook the moment right before (or right after) the form is processed. If Ninja Popups provides a hook for that (let's say 'ninja_popup_process_form' that is passing $form_data with the form that the user has submitted) this could be an example:

    <?php
    
    add_action( 'ninja_popup_process_form', 'mika_subscribe_user_when_popup_processed' );
    function mika_subscribe_user_when_popup_processed( $form_data ) {
    	if ( function_exists( 'incsub_sbe_insert_subscriber' ) ) {
    		$email = $form_data['email'];
    
    		/**
    		 * Params:
    		 * $autopt: True or false (default false)
    		 * $args: (optional) Array(
    		 * 		'note' => 'Subscribed through Ninja Popup',
    		 * )
    		 */
    		incsub_sbe_insert_subscriber( $email, $autopt, $args );
    	}
    
    }
  • Mika
    • The Bug Hunter

    Hey Ignacio.

    Yes that is a premium plugin. Would you want me to send it to you simply for test purposes?

    Your code logic makes completely sense. Would you be able to test it for me with the plugin if you have access to it? :slight_smile:

    Sincerely,
    Mika

  • Mika
    • The Bug Hunter

    Hey Ignacio.

    I just had a follow-up questions. My client wants to add more pop-ups using the Ninja Form plugin. Is that possible after we added the hook or will the function we hooked into the plugin be applied to all future forms created through the Ninja Forms plugin?

    Sincerely,
    Mika

  • Michael Bissett
    • Recruit

    Hey @Mika,

    Just to recap for everyone here, the hook that @Ignacio suggested inserting into the main plugin file (arscode-ninja-popups.php), right before line no. 720 (right before the echo json_encode($result)), was this:

    do_action( 'snp_submit_form', $result, $post_id );

    Now, as for the function he suggested creating, that would only affect a specific popup, as we're targeting the popup with the ID of 6387, as noted in the code below:

    add_action( 'snp_submit_form', 'ninja_sbe_subscribe', 10, 2 );
    function ninja_sbe_subscribe( $result, $popup_id ) {
    	if ( $popup_id === 6387 && $result['Ok'] ) {
    		incsub_sbe_insert_subscriber( $_POST['email'] );
    	}
    }

    You should be good with creating additional popups here. :slight_smile:

    Hope this helps!

    Kind Regards,
    Michael

  • Mika
    • The Bug Hunter

    Hey Ignacio.

    Thanks for your reply.

    If I a att: message to you with the link where you can download it, would you be able to help me. It is close to what we did last time, but this time I just need to add an checkbox input field to the pop-up theme I am using and then retrieve the data (I will explain further, if you can help me) :slight_smile:

    Sincerely,
    Mika

    • Ignacio
      • HummingBird

      I can give it a try, if it's not too much custom code I can provide a workaround. Please, send in a new message detailing what you're trying to do.

      Please, bear in mind that is weekend and that I'm gonna be off during saturday/sunday.

      Regards.
      Ignacio.

  • Mika
    • The Bug Hunter

    Hey Ignacio.

    Wonderful. Actually I have done most of the work, I just need the last touch to get it working. I will send the message with the link right away :slight_smile:

    That is not a problem at all! Have a great weekend!

    Sincerely,
    Mika

  • Mika
    • The Bug Hunter

    Hi Ignacio.

    Somehow the initial subscribe by email integration with ninja pop-up doesn't seems to be working any longer ( which is super strange ).

    Can you take a look to see how come? I have granted you admin access.

    The function we used was:

    add_action( 'snp_submit_form', 'ninja_sbe_subscribe', 10, 2 );
    function ninja_sbe_subscribe( $result, $popup_id ) {
    	if ( $popup_id === 6387 && $result['Ok'] ) {
    
    	$args = array(
    		  		'note' => 'Subscribed through Ninja Popup'
    		 );
    
    		incsub_sbe_insert_subscriber( $_POST['email'], false, $args );
    	}
    }

    Sincerely,
    Mika

    • Ignacio
      • HummingBird

      Hi @Mika

      The code is fine on SBE part.Have you updated Ninja Popups lately? Is the action present in Ninja Popups code?. Are you sure about the Popup ID?

      If the popup is not inserting the subscirber that's because the Ninja plugin, not SBE.

      Try to find out if the code is being executed (using a var_dump or an error_log).

      Regards.
      Ignacio.

  • Michael Bissett
    • Recruit

    Hey @Mika,

    First question on my mind here is... what's changed on your site recently? Have you done any of the following:

    - Updated any of your plugins, your theme, or WordPress itself
    - Installed a new plugin
    - Switched themes
    - Insert any new code, or remove any code

    Next up, what if you were to try doing a test signup of your own through the popup, and then check your site's error log? Any entries show up from around the time you tried signing up?

    Please advise,
    Michael

    Edit: Whoops, didn't see you here Ignacio!

  • Mika
    • The Bug Hunter

    @Ignacio and @Michael, thank you so much for both of your answers.

    After my post, I went ahead and did some further research. We had made some conditions to the do_action() code which we had created, so that was why it didn't take effekt.

    It works now again!

    Thanks a lot, and sorry for the bother!!

    Sincerely,
    Mika

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.