• Resolved Koff

    (@orenkolker)


    I have custom type person, and custom type hobby.
    If add a connection from person to hobbies.

    is it possible to add hobby from the connection metabox?

    Is this supported ?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author scribu

    (@scribu)

    No, it’s not supported and it’s not on the roadmap either.

    Thread Starter Koff

    (@orenkolker)

    Hi,

    Thank you for your answer.
    Is there a good reason for this not to be on the roadmap?

    i made some changes to the code:

    \ui\boxes.php:55 added:

    function add_to_post() {
    		$my_post = array(
    		 'post_title' => $_POST['post_title'],
    		 'post_author' => 1,
    		 'post_type' => $this->to
    	  );
    		wp_insert_post( $my_post );
    		die(1);
    	}

    \ui\boxes.php:112 added:

    <a href="#" class="p2p-addnew button" name="p2p-addnew">
    		<?php _e( 'Add new', 'posts-to-posts' ); ?>
    	</a>

    ui.css:22 added

    .p2p-footer .p2p-addnew {
    	float: right;
    }

    and ui.js:208 added:

    // Delegate p2p-addnew
    	$metabox.delegate('.p2p-addnew', 'click', function() {
    		var $button = $(this);
    
    		if ( $button.hasClass('inactive') )
    			return false;
    
    		var $x =$metabox.find('.p2p-search :text').val();
    		$button.addClass('inactive');
    
    		var data = $.extend( base_data, {
    			action: 'p2p_connections',
    			subaction: 'add_to_post',
    			post_title: $x
    		} );
    		$.post(ajaxurl, data, function(response) {
    			find_posts(1, $x);
    			$button.removeClass('inactive');
    		});
    
    		return false;
    	});

    And the result is as suggested in
    this post.

    What do you say?

    Plugin Author scribu

    (@scribu)

    Thanks for sharing your solution.

    However, it’s very confusing, at the moment, from a user experience standpoint.

    First thing I did after applying the changes is to click the “Add new” button. Since the search box was empty, it behaved just like the “Recent” button.

    Instead of automatically using what’s in the search field, you should be prompted to enter the post title (by changing the label of the search field and setting focus on the field).

    Since search is case insensitive, it’s very unlikely that what you searched for would be the final post title that you wanted.

    If you would like to take another swing at this, please consider forking on github and then submitting a pull request:

    https://github.com/scribu/wp-posts-to-posts/

    If you’re not confortable doing that, at least send me the modified plugin files in a zip – it’s faster for both of us and less error prone. My email: [email protected]

    PS: I was unwilling to add something like this because I was over-complicating it. You have opened my eyes! ??

    Thread Starter Koff

    (@orenkolker)

    Hi,

    You are absolutely right.

    I changed the code to do this the same interface as Add Category.
    I think its much better now.

    I will send you the code by mail.

    Thanks,
    Koff

    p.s. I chose to add the post as draft, thinking the user has to complete their details. I am not sure though this the right behavior.

    Plugin Author scribu

    (@scribu)

    Yes, creating it as a draft makes the most sense.

    The development version (0.8-alpha) incorporates the ability to create posts from the connections box.

    Hi
    I realize this is an old tread, but where in the code should i look to change the status of the posts created this way, to published instead of draft? I tried searching through the plugin files, but i couldnt find anything.( meaningfull to a php noob like myself ?? )

    Cheers
    Bonsak

    Plugin Author scribu

    (@scribu)

    You can use the ‘p2p_new_post_args’ filter:

    https://github.com/scribu/wp-posts-to-posts/wiki/Admin-box-filters

    Sweet!

    -b

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Create a new post from the connect metabox’ is closed to new replies.