Save user-specific options in WordPress admin

When you register your setting (assuming you’re using the settings API), you can get the current user object with wp_get_current_user. It returns a user object, and the property you’ll want to use in your setting is user_nicename — think of it like the user slug. <?php add_action( ‘admin_init’, ‘wpse27690_register_setting’ ); function wpse27690_register_setting() { $user = … Read more

Register theme customizer settings when theme activates [duplicate]

You need only use the default value on the wp_customize and that is all $wp_customize->add_setting(‘mytextoption’, array( ‘default’ => ‘defaultvalue’, ‘capability’ => ‘edit_theme_options’, ‘type’ => ‘option’, replace defaultvalue for the value you want, and when the user activate the theme this line will register the default value on the DB only when not exist on the … 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

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

Proper use of option_page_capability_{$page_name}

So in this hook is not exactly looking for the {$page_name}. Once I replaced the {$page_name} part of this filter to the {$option_group} parameter from my register_settings() function, all is well in the land of WordPress. Here is what my update needed to look like. function bf_ins_capability(){ return ‘edit_posts’; } add_filter( ‘option_page_capability_bf_insurance_settings’, ‘bf_ins_capability’);

update_option is not working!

I was able to get this working by using a separate option, that is not an array. I hate having to use multiple options like this but it works so I am going to go with it. My guess is that using update_option is not supported after implement the option with the settings API.

Two “.htaccess” Files Located in Different Directories?

In general, Apache will use the most specific .htaccess to the resource being requested. This means that, for accessing files in /httpdocs/wordpress/, /httpdocs/wordpress/.htaccess will be used. Access to /httpdocs/foo/ will use /httpdocs/foo/.htaccess and, if that doesn’t exist, it will use /httpdocs/.htaccess. If your document root is pointing to /httpdocs/wordpress/, then users will see http://www.example.com as … Read more

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