get USER ID in functions.php using user_register action

You are giving $wpdb->get_results a string for its second parameter. It should be a constant– ARRAY_N— meaning you need to remove the quotes $getunion = $wpdb->get_results( “SELECT value from wp_bp_xprofile_data where user_id = $getid AND field_id = 4”, ARRAY_N ); Since you claim it works in the second instance, I am assuming $wpdb compensates, but … Read more

Doing action based on input from options menu

You should post to the same URL and catch the submit ex: function option_page_html(){ if (isset($_POST[‘plugin_action’]) && $_POST[‘plugin_action’] == ‘post_url’){ include_once(plugin_dir_path(__FILE__).’post-video.php’); } ?> <div> <form action=”” method=”post”> <p><h3>Paste video url</h3></p> <input type=”text” size=”100″ name=”url” /><br/> <input type=”hidden” name=”plugin_action” value=”post_url”> <input type=”submit” value=”Post”/> </form> </div> <?php } note : this is an example and you should … Read more

Show only one category in main query, issues on tag page

If the only issue you want to correct is the output of single_tag_title, you can correct the value via a filter by grabbing the tag query var directly: function wpa90852_fix_tag_title(){ $tag = get_term_by( ‘slug’, get_query_var(‘tag’), ‘post_tag’ ); return $tag->name; } add_filter( ‘single_tag_title’, ‘wpa90852_fix_tag_title’ );

Password form redirection to belonging post

Here is all you need to make this work, plus your actual form of course: function dopasswordstuff(){ if(isset($_POST[‘homepagepassword’])){ global $wpdb; $post_password = trim($_POST[‘passwordfield’]); $post_id = $wpdb->get_var( $wpdb->prepare(“SELECT ID FROM $wpdb->posts WHERE post_password = %s”, $post_password) ); if (!empty($post_id)) { wp_redirect(get_permalink($post_id)); } exit; } } add_action(‘template_redirect’,’dopasswordstuff’); I simplified your function considerably by leveraging the fact that … Read more

Function in functions.php by url

You can check for the presence of a specific query variable, so http://www.example.com?my_listener=test. You check for this on the init hook and if it isn’t there you just quit early and WP goes about it’s business. If it is there, you can then do something, just don’t forget to exit at the end or the … Read more