Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

At the moment i use 3 custom post types to create "exhibitions", "guided tours" and "regular events".

My idea is to combine these events to one custom post type "event" and by creating of this custom post type there should be a pop-up option page where i can choose which type of event it should be.

I really do not want to do it later on the edit screen of the post because i would like to adjust the edit screen for every event type and display it prepared.

So i need some kind of hook/break after clicking on the "Add New" button and displaying the edit screen. Is it possible?

share|improve this question
2  
Maybe this can be adapted: wordpress.stackexchange.com/q/14403/12615 –  brasofilo Feb 1 '13 at 12:09
    
Thank you. I can work with that. –  Paul Geisler Feb 1 '13 at 12:43
add comment

1 Answer

This plugin does the same thing as what you are looking for: http://wordpress.org/extend/plugins/magic-action-box

It has a custom post type called action-box but has different types of action boxes that you can select when you create a new action box. The code you want is found inside the plugin's directory lib/classes/ProsulumMabAdmin.php.

Look for the method add_actions() and at the very end you should find something like this:

    /**
     * Hacky part followed from Premise. This is to make sure people
     * select an Action Box type before an Action Box type is actually created.
     * Requirements as of WP3.3: Custom post type needs to have support for comments
     * for this hack to work
     */
    add_action('admin_notices', array( &$this, 'possiblyStartOutputBuffering' ) );
    add_filter('wp_comment_reply', array( &$this, 'possiblyEndOutputBUffering' ) );

Follow the code - or just copy it and mod as needed, that's what open source all about :) - and you should be able to create your popup option page to select the type of event.

But, you also need to catch the selection of event type. For how Magic Action Box does it, again look at the method add_actions() and look for

add_action( 'admin_init', array(&$this, 'processSubmissions' ) );

follow the code and you'll find a section within the processSubmissions() method that processes the selection of an action box type.

share|improve this answer
    
Thank you. This is what i needed but i think this is too heavy to adapt it to my idea. Besides i would need a Pro version to test and understand it completely. I reconsidered my idea and the quickest and simplest solution is to use prepared custom meta boxes for different states. State 1: "Add new" -> Only one meta box with Title and event type dropdown... the publish button is manipulated to "Continue...". State 2: After the click on "Continue..."/Publish button the CPT Event is saved and there is a edit page reload, here i can check the event type and place specific custom meta boxes. –  Paul Geisler Feb 1 '13 at 13:43
1  
No need for the Pro version. And I'm not sure it's that heavy :) It just consists of the intercept page - the part where you display the page where the user can select the type (the hackish part) - and the part where you save the type that was selected (as postmeta). This is done by either checking the $_GET data (how MAB does it) or you could go the $_POST submit route. doesn't matter really since you will redirect it to the edit page once you have determined and saved the type. Anyway, your way is pretty good too. could be useful for certain workflows. Will keep it in mind :) thanks! –  WP Themes Feb 4 '13 at 16:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.