Execute PHP code in Javascript onclick

In simple terms, window.location.href is javascript, and will run in the browser, but PHP runs on the server. In order to execute update_usermeta() you need to open a page with that block of code on it. The best way to do this from a click is to use AJAX (javascript) to visit the URL on … Read more

Caching for logged in user and Ajax update

There are plugins that can help you with this, but they aren’t foolproof. My suggestion is W3 Total Cache, you should be able to exclude necessary files from the cache from there. Your best solution, however is to do caching on the serverside level as you will see better performance that way.

Capturing POST data

It points to options.php because it uses the Settings API. Well, not completely, but that’s not the point now. You should not change that. What you can do, to add your own logic: hook into the save process for that option: add_filter( “sanitize_option_webweb-member-status-group”, “your_extra_handler” ); function your_extra_handler( $input ) { if ( isset ( $_POST[‘your_extra_post_field’] … Read more

Why can wordpress not find the actions I add in my constructor?

Your constructor runs on the request from which you make the AJAX request, but not within the request that processes that AJAX request. The request that initially loads the page, and the AJAX request are two separate requests with no preservation of state between the two. This is not unique to WordPress, this is how … Read more

How to load wordpress sidebar using AJAX [duplicate]

Just go ahead and use a CSS media query to set the sidebar to display: none if the screen is too small, and provide your mobile users with some JavaScript that lets them selectively view it if they want to. Don’t worry about the loss in bit-and-cycle efficiency this causes; assuming that you get no … Read more