Using rewrite rule to access a view of a plugin from home page

This will create / handle your endpoint and attempt to load your php if the file is readable. Note: you won’t want to refresh the rewrite rules here but it’ll make sure you can test quickly. if (!class_exists(‘WPTestPluginEndpoint’)): class WPTestPluginEndpoint { const ENDPOINT_QUERY_NAME = ‘__my_test_plugin’; // WordPress hooks public function init() { add_filter(‘query_vars’, array($this, ‘add_query_vars’), … Read more

Save Theme Options (options.php) From The Frontend

You Do Not want to post /wp-admin/options.php from the front end , thats a bad idea and can cause problems. To updated Options from the frontend simply use update_option() and make sure you verify correctly. here is an example using your code with minor fixes: <?php if (isset($_POST[‘stylesheet’]) && isset($_POST[‘action’]) && $_POST[‘action’] == “update_theme”){ if … Read more

How can I edit a post from the frontend?

Just like the example you linked, but instead of using wp_insert_post() you use: wp_update_post() so your form becomes: <?php $post_to_edit = get_post($post_id); ?> <!– edit Post Form –> <div id=”postbox”> <form id=”new_post” name=”new_post” method=”post” action=””> <p> <label for=”title”>Title</label><br /> <input type=”text” id=”title” value=”<?php echo $post_to_edit->post_title; ?>” tabindex=”1″ size=”20″ name=”title” /> </p> <p> <label for=”description”>Description</label><br /> … Read more

Get user input from a form

Use wp-admin/admin-post.php as form action handler, and bind your custom function as callback to that. A simple example for email updates. We will use a shortcode named [userform] here, but you can use a template too. add_shortcode( ‘userform’, ‘wpse_75723_userform’ ); add_action( ‘admin_post_update_user_email’, ‘wpse_75723_update’ ); /** * Create the form. */ function wpse_75723_userform() { $here = … Read more

Developing a secure front end posting form

Hopefully the code will be sufficient to describe the key points, but please do comment if you have any further questions: <?php class WPSE_Submit_From_Front { const NONCE_VALUE = ‘front_end_new_post’; const NONCE_FIELD = ‘fenp_nonce’; protected $pluginPath; protected $pluginUrl; protected $errors = array(); protected $data = array(); function __construct() { $this->pluginPath = plugin_dir_path( __file__ ); $this->pluginUrl = … Read more

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