Creating a user’s own folder on user registration

You can use the user_register action to hook into the register proces and then create the user directory with wp_mkdir_p. function create_user_dir($user_id) { $user_info = get_userdata( $user_id ); $upload_dir = wp_upload_dir(); $user_dir = $upload_dir[‘basedir’] . ‘/user_dirs/’ . $user_info->user_login; wp_mkdir_p($user_dir); } add_action( ‘user_register’, ‘create_user_dir’); This example makes a directory in uploads/user_dirs. http://codex.wordpress.org/Plugin_API/Action_Reference/user_register http://codex.wordpress.org/Function_Reference/wp_mkdir_p

Adding a Variable Product in WooCommerce Programatically

Found the solution to make a product attribute, a variation. Lets say we have: wp_set_object_terms( $post_id, ‘XL’, ‘pa_size’ ); Above is a custom attribute (a size attribute). In order to make it a variation you need to do this: $thedata = Array(‘pa_size’=>Array( ‘name’=>’pa_size’, ‘value’=>”, ‘is_visible’ => ‘1’, ‘is_variation’ => ‘1’, ‘is_taxonomy’ => ‘1’ )); update_post_meta( … Read more

Plugin not showing in dashboard

If the plugin headers are correct, then the only option that comes to my mind is that the owner and permissions of the plugin file or its directory (if it is in one) are incorrect and WordPress cannot read the plugin file. Other than simply being logically important, if you check the source you can … Read more

How to generate expiring URL?

Ok I came up with this add_action( ‘wp_loaded’, ‘my_create_questionnaire_link’); function my_create_questionnaire_link(){ // this check is for demo, if you go to http://yoursite.demo/?create-my-link, you will get your unique url added to your content if( isset( $_GET[‘create-my-link’] ) ){ // This filter is for demo purpose // You might want to create a button or a special … Read more

Get a button for in the Editor

There’s an easy way. Open functions.php and add this code. It works for many html entities // got this form http://www.sycha.com/wordpress-add-hr-button-tinymce-visual-editor function enable_more_buttons($buttons) { $buttons[] = ‘hr’; /* Repeat with any other buttons you want to add, e.g. $buttons[] = ‘fontselect’; $buttons[] = ‘sup’; */ return $buttons; } add_filter(“mce_buttons”, “enable_more_buttons”); //add_filter(“mce_buttons_2”, “enable_more_buttons”); // add to … Read more

Remove WordPress Toolbar buttons

function mytheme_admin_bar_render() { global $wp_admin_bar; $wp_admin_bar->remove_menu(‘wp-logo’); } add_action( ‘wp_before_admin_bar_render’, ‘mytheme_admin_bar_render’ ); For specific user roles you can wrap the add_action in a conditional, something like if(current_user_can(‘editor’)){ add_action( ‘wp_before_admin_bar_render’, ‘mytheme_admin_bar_render’ ); } http://codex.wordpress.org/Roles_and_Capabilities

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)