WP Plugin for Terms of Use

I wrote something like that in the past that check for a cookie before loading the page and if the cookie wasn’t found the page would display something like the terms of services and a checkbox to agree, so only after the guest agrees he can see the content. i’ll see if i can find … Read more

Need to include and redirect template from plugin

Your portfolio_newpage_template function does not result in a 404 when I try it, but it is not going to work either. locate_template will always load from theme directories, so it will never find your plugin file. You can see that in the source. __FILE__ is going to refer to the file with the function in … Read more

Cron Job not working in plugin

The cron event needs to be registered on the plugin activation hook like so: register_activation_hook( __FILE__, ‘activate_cron’ ); function activate_cron() { wp_schedule_event( current_time( ‘timestamp’ ), ‘hourly’, ‘the_function_to_run’ ); } The the_function_to_run defined in the wp_schedule_event needs to be your function that you want to run at the time interval. Note: When you say something is … Read more

While Using Static Pages, How Can I Get /blog into the URL of Each Post?

In admin under Settings > Permalinks, select Custom Structure and enter /blog/%postname%/. This will prepend /blog/ to categories and tags by default, and any custom post types and taxonomies where you have not registered them with the with_front argument set to false. you can remove it from the built-in category and tag taxonomies by setting … Read more

delay function on publish?

publish_post is called after post is published! So, you already got covered. but if you want to run an action after a certain time of the post is published, it’s better to write a cron job. For example, if you need to run the function after 5 minutes of the post is published, you need … Read more

Changing widget options via the functions.php when there are no hooks

After some digging, I’ve arrived at a solution (explained in the comments) – function change_widget_configuration() { $options = get_option(‘widget_some-widget’); // retrieve the options for all occurrences of the named widget* $widget_number = 3; // the id number of the specific occurrence of the widget whose options you wish to alter (this can be obtained simply … Read more

Getting User email on logout. wp_logout

wp_get_current_user() will never work in this hook, because, wp_logout action fires after user is logged out: session destroyed, cookies cleared and current user is set to 0. But wp_logout action recieves $user_id. I will give you a working example, because I do not familiar with your custom functions. //pass $user_id as argument function mmd_JudgeLogoutCheck($user_id) { … Read more