WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Quick Press Widget] "Dewidgetize" it - for anonymous posting page (6 posts)

  1. rwanito
    Member
    Posted 4 years ago #

    Hi there,

    I modified quick-press-widget to allow anonymous posting (without registering, added a captcha) and include the form in a page instead of in the sidebar (comments are in french, ask if you need a translation):

    The plugin file :

    function widget_QPW_init()
    
    {function widget_QPW($args)
    
        {if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'post' && $_POST['captcha'] == 2010 ) {	check_admin_referer( 'new-post' );
    
    			$user_id		= $current_user->user_id;
    
    			// définir ici l'ID de l'auteur attribué automatiquement
    
    			if (!$user_id) {$user_id = 2;}
    
    			$post_content	= $_POST['posttext'];
    
    			$tags			= $_POST['tags'];
    
    			$char_limit		= 40;
    
    			$post_title		= $_POST['title'];
    
    			$post_name		= $_POST['name'];
    
    			$post_id = wp_insert_post( array(
    
    				'post_author'	=> $user_id,
    
    				'post_title'	=> $post_title,
    
    				'post_content'	=> $post_content,
    
    				'tags_input'	=> $tags,
    
    				'post_status'	=> 'publish'
    
    			) );
    
    		}
    
        }
    
        // Need to register the widget and the control form.
    
        register_sidebar_widget(__('Quick Press Widget', 'QPW'), 'widget_QPW');
    
    }
    
    function widget_QPW_deactivate()
    
    {
    
        delete_option('widget_QPW');
    
    }
    
    register_deactivation_hook(__FILE__, 'widget_QPW_deactivate');
    
    add_action('plugins_loaded', 'widget_QPW_init');

    The form : (include this in a page template)

    <div id="postbox" style="background-color:#EEE; padding: 15px; margin: 5px 0px; -moz-border-radius: 10px; -khtml-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px;" >
    	<form id="new_post" name="new_post" method="post" action="<?php bloginfo( 'url' ); ?>/">
    		<input type="hidden" name="action" value="post" />
    		<?php wp_nonce_field( 'new-post' ); ?>
    		<label for="title">Titre :</label>
    		<br />
    		<input type="text" name="title" id="title" style="width:95%; height: 25px; border: 1px solid #99afbc; margin: 5px 0 10px 0;" />
    		<br />
    		<label for="posttext">Article :</label>
    		<br />
    		<textarea name="posttext" id="posttext" rows="3" style="width:95%; height: 300px; border: 1px solid #99afbc; margin: 5px 0 10px 0;" ></textarea>
    	  <br />
    		<!-- <label for="tags">Mots-clefs :</label>
    		<br />
    		<input type="text" name="tags" id="tags" style="width:95%; height: 25px; border: 1px solid #99afbc; margin: 5px 0 10px 0;" />
    		<br /> -->
    		<label for="tags"><strong>Anti-robots :</strong> En quelle année sommes-nous ?</label>
    		<br />
    		<input type="text" name="captcha" id="tags" style="width:95%; height: 25px; border: 1px solid #99afbc; margin: 5px 0 10px 0;" />
    		<br />
    		<center><input id="submit" type="submit" value="Publier" style="background-color: #EEE; border: 1px solid #333; color: #333; font-weight: bold; padding: 5px 8px;" /></center>
    	</form>
    </div>

    TODO :

    I still nedd to activate the plugin AND to register the widget in the sidebar for this to work.
    I would like to include the plugin file in my functions.php.

    Do you know which lines I have to copy, wich ones I can erase ?

    Thanks for sharing !

    http://wordpress.org/extend/plugins/quick-press-widget/

  2. rwanito
    Member
    Posted 4 years ago #

    It works !

    So, this is the lines you need to copy in functions.php :

    function AnonPost($args)
    {
    	if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'post' && $_POST['captcha'] == 2010 ) {
    
    		check_admin_referer( 'new-post' );
    
    		$user_id		= $current_user->user_id;
    		// définir ici l'ID de l'auteur attribué automatiquement
    		if (!$user_id) {$user_id = 2;}
    		$post_content	= $_POST['posttext'];
    		$tags			= $_POST['tags'];
    		$char_limit		= 40;
    		$post_title		= $_POST['title'];
    		$post_name		= $_POST['name'];
    		$post_id = wp_insert_post( array(
    			'post_author'	=> $user_id,
    			'post_title'	=> $post_title,
    			'post_content'	=> $post_content,
    			'tags_input'	=> $tags,
    			'post_status'	=> 'publish'
    		) );
    	}
    }
    add_action('wp_head', 'AnonPost');

    With this, you can deactvate the plugin and the widget.
    See up for the form page
    Thank you dreamcolor

  3. zvhipp
    Member
    Posted 4 years ago #

    Also way to include category if possible, thanks.

  4. inapan
    Member
    Posted 4 years ago #

  5. craigstruck
    Member
    Posted 3 years ago #

    I need a little more help of how this works. I installed the plug-in and want it in the side bar for anyone to make a post. I am very new to this and there is a lot of code on this page. Which code do i copy and paste and where. I would also need a translated english version. Thanks for your time

  6. nigelparrydotnet
    Member
    Posted 3 years ago #

    @rwanito Thanks for posting this. Have you tried this on WordPress 3 and does it work?

    Are you/anyone else aware of any other plugins that allow for anonymous publishing, and is there a way of confining the posting to a single category?

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic