I want to reset user’s post meta after successfully login

wp_login action passes 2 arguments $user_login and $user. The second argument is the object of WP_User class, which you can use to get user id from: function reset_dismiss_message( $user_login, $user ) { update_user_meta( $user->ID, ‘tgmpa_dismissed_notice’, false ); } add_action( ‘wp_login’, ‘reset_dismiss_message’, 10, 2 );

Plugin code will not work properly inside a class [closed]

Enable the magic method __construct You have to change the following line $MySubBoxClass = new MySubBoxClass; Into $MySubBoxClass = new MySubBoxClass(); This way the __construct() magic method will be used. The add_action methods aren’t called now. Error in html_form_func( $object ) Change public function html_form_func( $object ) //Creates the HTML form and outputs its value … Read more

Widget where it can make changes to the container

I would not recommend that. Much easier to use a clearfix hack to force clearing and just add that style to your widget. Clearfix hacks are transparent: it doesn’t matter if they happen on all elements there is no visible difference, other than clear floats. Somewhere in your themes style.css: .widget:before, .widget:after { content: ” … Read more

Get variable value based on string constant

You can do that, but you shouldn’t: Keep the global namespace clean. Each name in the global namespace is a collision candidate. Making a variable global, a constant or a function increases the likelihood of a collision, no matter how good your prefixes are. Constants are the slowest global types. Yes, that’s micro-optimization, but why … Read more

force jQuery to load in the head

Edit: new solution, based on one of the comments. If you are using wp_enqueue_script to load your js file, make sure jQuery is a dependency so that it gets called before your code: wp_enqueue_script( ‘my_script’, ‘my-script.js’, array( ‘jquery’), $ver, true ); You can then remove the original enqueue call you had since jQuery will be … Read more

How to add a button to check the emails of my domain?

Based on my comment in the Question, I tested the solution of adding a menu item that opens an iframe in its screen. As expected, Gmail doesn’t allow to be displayed in an iframe. But a regular Horde Webmail does work. add_action( ‘admin_menu’, ’embed_webmail_wpse_91871′ ); function embed_webmail_wpse_91871() { // Reference: http://codex.wordpress.org/Function_Reference/add_menu_page // Check it, specially … Read more