WordPress.org

Forums

Post From Site
No visible reaction after page creation (24 posts)

  1. wewetho
    Member
    Posted 3 years ago #

    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/

  2. collaboratorfab
    Member
    Posted 3 years ago #

    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

  3. dylanbog
    Member
    Posted 3 years ago #

    I have this problem also. Any solutions?

  4. chang_001
    Member
    Posted 3 years ago #

    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

  5. wewetho
    Member
    Posted 3 years ago #

    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

  6. andyhoyland
    Member
    Posted 3 years ago #

    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

  7. chang_001
    Member
    Posted 3 years ago #

    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

  8. chang_001
    Member
    Posted 3 years ago #

    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.

  9. wewetho
    Member
    Posted 3 years ago #

    Hi Chang,

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

    Best,

    Felix

  10. Sapphire_luna232
    Member
    Posted 3 years ago #

    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

  11. matiou34
    Member
    Posted 3 years ago #

    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

  12. simoniturra
    Member
    Posted 3 years ago #

    Hi Sapphire_luna2323:

    How will be the final file?

    Thanks! :D

  13. Sapphire_luna232
    Member
    Posted 3 years ago #

    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

  14. simoniturra
    Member
    Posted 3 years ago #

    Thanks you!!! :D

  15. Sapphire_luna232
    Member
    Posted 3 years ago #

    You're very welcome! ^^

  16. hudsons4
    Member
    Posted 3 years ago #

    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

  17. chucktownfound
    Member
    Posted 3 years ago #

    Hey Sapphire...

    thanks for taking the time to do this, however, your solution did not work for me. I followed the directions exactly and got this error:

    Notice: Undefined index: post_type in /home/content/72/8081472/html/morningfinger/wp-content/themes/wp-clear/theme-metaboxes.php on line 393

    Notice: Undefined index: layout_noncename in /home/content/72/8081472/html/morningfinger/wp-content/themes/wp-clear/theme-metaboxes.php on line 400
    {"image":"","error":"","success":"Post added, please wait to return to the previous page.","post":31}
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/72/8081472/html/morningfinger/wp-content/themes/wp-clear/theme-metaboxes.php:393) in /home/content/72/8081472/html/morningfinger/wp-includes/pluggable.php on line 866

    Any thoughts?

  18. luchosar
    Member
    Posted 3 years ago #

    I do not work: (

  19. murtitangkas
    Member
    Posted 3 years ago #

    its work for me.., thanks!!!

  20. mathinker
    Member
    Posted 3 years ago #

    First time posting here. I got similar problem with pfs after initial install, glad to find Sapphire and Chang's workaround, applied Sapphire's workaround, it did not work for me initially, but after commenting out json_encode statement in pfs-submit.php, it worked:

    $pfs = pfs_submit($_POST,$_FILES);
    <strong>//echo json_encode($pfs);</strong>
    //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($pfs, true)."</pre>\n";
    wp_redirect("http://localhost/analystnews");
    exit;
  21. bhdz
    Member
    Posted 3 years ago #

    Nothing of the above worked for me, any other ideas?
    Please help

  22. maverhick80
    Member
    Posted 3 years ago #

    idem bjdz... Nothing of the above worked for me...

    these my error:

    "Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, postmaster@site.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log."

  23. prak_test
    Member
    Posted 2 years ago #

    DOnt bite your nail too much just add the following line
    jQuery('#pfs-alert').addClass('show-success').html('<span>'+data.success+'</span>').show();
    before
    jQuery('form.pfs').reset();
    and remove the
    location.reload();

  24. prak_test
    Member
    Posted 2 years ago #

    Or you may remove the pfs-script.js with

    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(this).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 = jQuery.parseJSON(request.responseText);
                    if (data && data.error) {
                    	//alert(data);
                        jQuery('#pfs-alert').addClass('show-error').html('<span>'+data.error+'</span>').show();
                        jQuery('.pfs-post-form #post').val('Post');
                    } else {
    					jQuery('#pfs-alert').addClass('show-success').html('<span>'+data.success+'</span>').show();
                        jQuery('form.pfs').reset();
                        //location.reload();
                    }
                }
            });
            return false;
        });
    
    jQuery("#post-type").change(function(){
    		var vals = jQuery(this).val();
    		if(vals == 'text')
    			 jQuery('.type-value').hide();
    		else
    			jQuery('.type-value').show();
    	});
    
    });

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Post From Site
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic