Let user subscribe to specific categories

You can give them this url http://www.example.com/?cat=42&feed=rss2 This one if permalinks are enabled http://example.com/category/categoryname/feed Replace the site url & also the cateogries id or slug with the correct one UPDATE IN RESPONSE TO COMMENT Display a list of categories to the user maybe with wp_dropdown_categories. Save the id of the category the user subscribed to … Read more

How to get the ID of the currently logged in user?

get_current_user_id() effectively does what @Giri had described in the first snippet. The internal WordPress function-call chain eventually calls get_currentuserinfo() which already checks if there is a WP_User object, meaning a user is logged in. Thus, from what I can see in the linked code, get_current_user_id() always returns the ID of the user that is logged … Read more

How to get the post content after WordPress post processing?

If by “post processing” you mean the autoformatting, the shortcode processing, that sort of thing, then you want to pass the content through the the_content filters. $my_id = 7; $post_id_7 = get_post($my_id); $post_content = $post_id_7->post_content; $post_content = apply_filters(‘the_content’,$post_content); http://codex.wordpress.org/Function_Reference/apply_filters You can see much of what will be applied by default by looking at the source … Read more

How to access function from outside of a class within this class in WP plugin?

Create a static getter for your class instance: class DD_Awesome_Plugin { /** * Plugin main instance. * * @type object */ protected static $instance = NULL; /** * Access plugin instance. You can create further instances by calling * the constructor directly. * * @wp-hook wp_loaded * @return object T5_Spam_Block */ public static function get_instance() … Read more

Can I use a form in a dashboard widget?

There are two options to use forms in a dashboard widget: Use the parameter control_callback. See the Codex wp_add_dashboard_widget( ‘my_id’, // $widget_id ‘my_name’, // $widget_name ‘my_render_widget’, // $callback ‘my_control’ // $control_callback ); function my_control() { // print some form elements, WordPress will handle the <form> tag. } If you want to use a form in … Read more

How use %like% in sql statement wordpress

$wpdb->prepare() doesn’t actually fully support sprintf() placeholders. From the Codex: The query parameter for prepare accepts sprintf()-like placeholders. The %s (string), %d (integer) and %f (float) formats are supported. It’s not entirely obvious from that but the argument swapping formats (e.g. %1$d) are not supported (in any case you have the incorrect syntax: it should … Read more

How to trigger an action with a URL

As @toscho says you need an endpoint. Note code is untested. /** * Flush rewrite rules */ function install_my_plugin() { my_plugin_endpoint(); flush_rewrite_rules(); } register_activation_hook( __FILE__, ‘install_my_plugin’ ); /** * Flush rewrite rules */ function unistall_my_plugin() { flush_rewrite_rules(); } register_deactivation_hook( __FILE__, ‘unistall_my_plugin’ ); /** * Add the endpoint */ function my_plugin_endpoint() { add_rewrite_endpoint( ‘action’, EP_ROOT ); … Read more

Making Quote Plugin more efficient

Is there more efficient ways to validate the quotes using the WordPress api? I think you should set a nonce for the form You also should check if current user has capability to save quote To get properly sanitize values form $_POST look at filter_input and/or filter_input_array I don’t see performance issues on validation, but … Read more