Support » Plugin: Post From Site » [Plugin: Post From Site] No visible reaction after page creation

  • Hello,

    This is a great plugin! But after hitting the “post” button, there is no visible reaction. This is of course extremely confusing. It happens in the embedded form as well as in the popup version (the form/popup just stay as they are).

    It would be great if it would either redirect to the new page/post, or if one could define to which page one will be directed.

    I hope somebody can help me with this.

    Thanks!

    Felix

    http://wordpress.org/extend/plugins/post-from-site/

Viewing 15 replies - 1 through 15 (of 23 total)
  • Hi all,

    I have the same problem exposed above, and it’s a problem because the user doesn’t know if the post has been published. Any way to fix it?

    Thank you very much!

    Collab

    I have this problem also. Any solutions?

    You will have to take out ‘pfs’ from the form class tag in the method get_form().

    $out .= "<form class='pfs' id='pfs_form' method='post' action='".plugins_url("pfs-submit.php",__FILE__). "' enctype='multipart/form-data'>\n";

    should become :

    `
    $out .= "<form class='' id='pfs_form' method='post' action='".plugins_url("pfs-submit.php",__FILE__). "' enctype='multipart/form-data'>\n";
    `

    From there, you will have to open the file “pfs-submit.php and modify the bit in the conditional if (!empty ($_POST)), located at the end of the file.

    It worked for me, quick and dirty, hope it does for you too.

    Chang

    Hi Chang,

    What do you mean by modify the bit in the conditional? What do I have to modify? For a non-coder like me its really not obvious…

    Thanks,

    Felix

    Hi Felix

    Not sure if this is going to be much use to you – but I’ve encountered the same problem.

    I’m not saying it’s not a problem with the plugin but I found that the problem only occurred on my homepage which had some additional jquery going on. When I take that jquery out of the equation I get a proper redirect.

    Doesn’t really solve anything (yet) as I need the jquery on my homepage – and for you, as I don’t know what theme you’re using or anything like that, it’s not much use – but I’m pretty sure I’m looking in the right place for a fix now!

    I’ll let you know if/when I get further!
    Regards
    Andy

    Hello Felix,
    My quick fix (previous posting) was to delete the class, with the effect that “jQuery(“form.pfs”).ajaxSubmit({…” couldn’t be identified and run. You would then have to write a redirection link for the user to click on.

    The problem occurs when the function jQuery.parseJSON fails to parse the argument, because of the way the responseText is structured (a JSON versioning problem? I don’t know)

    Another fix, is to parse the responseText yourself, instead of letting jQuery.parseJSON do it.

    Replace the part in the file “pfs-script.js” that goes “complete: ...setTimeout( "location.reload()", 2*1000 );}}” with the following lines:

    complete: function(request,textStatus,error) {
    
    					data = {};
    					try {
    						 data = jQuery.parseJSON(request.responseText); //bug here!!!
    					} catch(err){
    						// alert( "#error:"+err);
    					};
    
    					resp = request.responseText;
    					res = resp.match(/\[.*\].*/g);
    					for(var i in res){
    						arr = res[i].split("=>");
    						key = arr[0].substr(1, arr[0].lastIndexOf(']')-1);
    		 				val = arr[1].replace("\n",'').replace("\t",'');
    						data[key] = (val.length>0) ?  val: null;
    					}
    					if (data.error.length>1) {
    						jQuery('#pfs-alert').addClass('error').html('<p>'+data.error+'</p>').show();
    						jQuery('.pfs-post-form #post').val('Post');
    					} else {
    						jQuery('#pfs-alert').addClass('error').html('<p>'+data.success+'</p>').show();
    						jQuery('form.pfs').reset();
    						setTimeout( "location.reload()", 2*1000 );
    					}
                }

    Hope it works for you.
    Chang

    An update to my previous code, with minor alterations. Easiest is to replace the whole content of the file pfs-script.js with this:

    jQuery(document).ready(function(){
    	jQuery(".pfs-post-link").click(function(){
    		var $box = jQuery(this).siblings('div');
    		if ('relative' == jQuery(this).parents('article').css('position')) {
    			var top = 0;
    			var diff = jQuery(this).parents('article').offset();
    			var left = ( jQuery(window).width() - $box.width() )/2 - diff.left;
    		} else {
    			var top = 90;
    			var left = ( jQuery(window).width() - $box.width() )/2;
    		}
    		if (top<0) top = 50;
    		$box.css({top:top+"px",left:left+"px"}).show();
    	});
    	jQuery(".closex").click(function(){
    		jQuery(this).parent().hide();
    	});
        jQuery("form.pfs").submit(function() {
    
           jQuery("form.pfs").ajaxSubmit({
                type: "POST",
                url: jQuery(this).attr('action'),
                dataType:'json',
                beforeSend: function(){
                    jQuery('.pfs-post-form #post').val('posting...');
                },
                complete: function(request,textStatus,error) {
    
    					data = {};
    					try {
    						 data = jQuery.parseJSON(request.responseText); //bug here!!!
    					} catch(err){
    						// alert( "#error:"+err);
    						resp = request.responseText;
    						res = resp.match(/\[.*\].*/g);
    						for(var i in res){
    							arr = res[i].split("=>");
    							key = arr[0].substr(arr[0].indexOf('[')+1, arr[0].lastIndexOf(']')-1);
    							data[key] = arr[1];
    						}
    					};
    
    					if (data.error.length>1) {
    						jQuery('#pfs-alert').addClass('error').html('<p>'+data.error+'</p>').show();
    						jQuery('.pfs-post-form #post').val('Post');
    					} else {
    						jQuery('#pfs-alert').addClass('success').html('<p>'+data.success+'</p>').show();
    						jQuery('form.pfs').reset();
    						setTimeout( "location.reload()", 2*1000 );
    					}
                }
            });
            return false;
        });
    });

    Note: I couldn’t figure out why data.error.length was set to 1, even though there was no error and the value appeared empty. This is why I wrote “if ( data.error.length > 1 )” instead of “if ( data.error.length > 0 )”. Not pretty, but shouldn’t break the code though.

    Hi Chang,

    I replaced the pfs-script.js with your code but now the pop-up form is not opening anymore.

    Best,

    Felix

    Chang-

    Thanks for the fix; after experiencing the same ‘no visible reaction’ error, I deleted the ‘pfs’ class, added wp_redirect, and after initially getting an “unexpected ‘:'” error, placed double quotes “” around the address I was trying to redirect to. Worked like a charm!

    Thanks again,
    ~Anna

    Hi @sapphire_luna232

    I have the same problem. Could you please explain me how and where did you add a redirection ?

    Thanks a lot,

    Mathieu

    Hi Sapphire_luna2323:

    How will be the final file?

    Thanks! 😀

    Hi guys,

    There are two files you have to modify for this fix. To access them, go to your Dashboard –> Plugins –> Editor. Select ‘Post from Site’ in the dropdown menu on the upper right, hit ‘Select’. You should see a list of editable files for the plugin appear as blue links below the dropdown menu.

    The first file you need to edit for this fix is: “post-from-site/post-from-site.class.php

    There should be a line somewhere that looks something like:

    $out .= “<form class=’pfs’ id=’pfs_form’ method=’post’ action='”.plugins_url(“pfs-submit.php”,__FILE__). “‘ enctype=’multipart/form-data’>\n”;

    near the beginning of this line, where it says: form class = ‘pfs’, delete ONLY the pfs (not the single quotes around it), so that it now says

    $out .= “<form class=” id=’pfs_form’ method=’post’ action='”.plugins_url(“pfs-submit.php”,__FILE__). “‘ enctype=’multipart/form-data’>\n”;

    The second file you want to edit is: “post-from-site/pfs-submit.php

    scroll to the bottom of the code. You should see a few lines that go something like:

    if (!empty($_POST)){
    $pfs = pfs_submit($_POST,$_FILES);
    echo json_encode($pfs);
    //echo “<pre style=\”border:1px solid #ccc;margin-top:5px;\”>”.print_r($pfs, true).”\n”;

    Below the last line, add:

    wp_redirect(“http://www.blah-blah-redirect-to-this-address.com”);
    exit;

    so that the line now reads:

    if (!empty($_POST)){
    $pfs = pfs_submit($_POST,$_FILES);
    echo json_encode($pfs);
    //echo “<pre style=\”border:1px solid #ccc;margin-top:5px;\”>”.print_r($pfs, true).”\n”;
    wp_redirect(“http://www.blah-blah-redirect-to-this-address.com”);
    exit;

    add the address you wish to redirect the user to upon successful submission of a post in place of the “blah-blah-etc”. Make sure you use double quotes “like this” instead of single quotes ‘like this’ around your address, or your browser may read the code and result in an “unexpected ‘:’ ” error.

    Personally, I redirected my users to a page I had created with a ‘Your submission has been successful!” message so that they would be reassured that their submission had gone through, but you could also redirect users to your homepage, an external page somewhere on the net outside of your WordPress site, etc.

    Hope that helps, let me know if you have any more questions!
    ~Anna

    Thanks you!!! 😀

    You’re very welcome! ^^

    Hey Sapphire – Awesome! Thanks a million for this… This now makes a great plugin. I have also added the notifier plugin so I am emailed every time a new post needs approving – 🙂 (big smile)

    One question though – the CSS of this is form, if possible, I would like to change. The blocks saying ‘Title’ and Content, I would like to move..

    I also want to make the width adjustable – on my mobile using WPtouch it does not fit correctly..

    Does anyone have any ideas?

    Thanks again

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘[Plugin: Post From Site] No visible reaction after page creation’ is closed to new replies.