Multi-part form and wp_redirect()

You have a form like <form action=”http://some/url/form_two.php” method=”POST”> <input type=”whatever” value=”nothing” /> <input type=”hidden” name=”form_one_displayed” value=”1″ /> <input type=”submit” value=”Send” /> </form> in e.g form_one.php In form_two.php you validate the data that was send (or not) <?php $result = do_some_validation_with( $_POST ); if ( false == $result ) wp_redirect( ‘form_one.php’ ); else display_form_two(); function do_some_validation_with( … Read more

Fetch the input type date value via ajax

If you want to post the value as soon as user has entered the date and click somewhere else, this might help you: jQuery(‘#your-name’).on(‘blur’, function(){ var date_Value = this.value; var ajaxdata = { action: ‘process_date’, date_value: date_Value }; jQuery.post(ajaxurl, ajaxdata, function(res){ /* whatever you want to do, res contains the output generated by your php … Read more

Changing upload directory for plugin uploads only

There must be something identifiable about your form data, such as your input names. Check for one or more of those and process accordingly. function custom_upload_dir($args) { if (isset($_POST[‘something’])) { $args[‘path’] = $args[‘basedir’] . “/mypath” . $args[‘subdir’]; $args[‘url’] = $args[‘baseurl’] . “/mypath” . $args[‘subdir’]; } return $args; } After some investigation, the only things I … Read more

Client Profiles

Do they clients ever need to log in? If so, I would make them users and give them a custom role. Then add all the meta to the user profile page for that user only. In that case, see: http://codex.wordpress.org/Roles_and_Capabilities If not, I would make them custom post types and use something like Scribu’s Posts-to-Posts … Read more

How to check during “pre_get_posts” if WP performing default query for specific custom template?

As you describe the timing would not quite work. During WP core load: main query is created and processed into query variables (with pre_get_posts being one of the hooks able to influence the results) then template-loader.php uses conditionals (dependent on those query variables) to determine template to use So at the point of pre_get_posts you … Read more

Adding querystring variable breaks admin URLs

You’re recieving this error because WordPress notices the post_type query argument and that sampletype is a valid registered post type, and thinks you’re on an edit page. Try using a different query arg then post_type. Note that admin.php?page=plugin-slug-posttypes-add&post_type=thisisnotaposttype and admin.php?page=plugin-slug-posttypes-add&foo=bar will both work fine.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)