• Hi Greg,

    After hitting publish, is it possible to automatically redirect back to “add” page, my users are getting confused and it much easier for what am trying to setup here.

    Kindly assist.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    automatic redirect is not really possible because once the Ad is saved and its status is set some content is already printed in the browser and at this point the browser cannot run a redirect.

    Can you let me know if you are charging your users (and if so with WC or the default payments module) and if the ads are being moderated? Maybe some other workaround would be possible.

    Thread Starter pmmungai86

    (@pmmungai86)

    The ads are all free and yes I will moderate them.

    What am looking forward to do is once an ad is published the user is redirected to “add” to post another ad.

    Thread Starter pmmungai86

    (@pmmungai86)

    It would be great maybe after clicking publish, instead of displaying other information about the ad it can then redirect to manage or add please!

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    hmm we do not really have such functionality built-in, but you can try adding in your theme functions.php file the code below

    
    add_action( "template_redirect", function( $tpl ) {
        if( adverts_request( "_adverts_action" ) != "save" ) {
            return $tpl;
        }
        
        include_once ADVERTS_PATH . "includes/class-shortcode-adverts-add.php";
        
        $shortcode = new Adverts_Shortcode_Adverts_Add();
        $shortcode->load_args_from_checksum();
        $shortcode->init();
        $save = $shortcode->action_save();
        if( stripos( $save, "Could not validate." ) === false ) {
            wp_redirect( "https://example.com" );
            exit;
        } 
    
        return $tpl;
    } );
    

    it should redirect the user to some other page instead of showing the default success message (of course change in the code “https://example.com” to some actual URL you want to redirect the user to).

    Also after adding the code, please double check if the ads submission works correctly as this is kind of a “dirty” hack to bypass the last submission step.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Publishing an Ad’ is closed to new replies.