How can the Wordpress Theme Customizer be used only for author.php and settings will be saved per user basis. By which every user can customize their own author.php.

How can it be achieved?

  • Exactly what setting are you trying to manipulate? – s_ha_dum May 27 '15 at 20:52
  • options data to user_meta @s_ha_dum – mha May 27 '15 at 20:53
  • Please be specific. That doesn't tell me what you are trying to do. – s_ha_dum May 27 '15 at 20:55
  • I want to use Wordpress Theme Customize API codex.wordpress.org/Theme_Customization_API to give user options to modify their own auhtor.php. Theme Customize API save all its settings to wp_options table. If somehow it can be done to save user_meta per user basis. It could be possible to allow user to use Theme customizer only for author.php – mha May 27 '15 at 21:13
  • You can add a capability on Customizer, that only roles with this capability can use the Customizer. – bueltge May 27 '15 at 21:30

First, you will need to generate customizer settings depending on the current user. So there are two conditions to be met: the setting must only be accessible to the current user and this setting must be unique to him.

// Only do this for contributors and up
if (current_user_can('edit_posts')) {
   // retrieve author id
   global $current_user;
   $author_id = $current_user->ID
   // generate customizer setting for this author only
   $wp_customize->add_setting( 'header_color_' . $author_id , array(
     'default' => '#000',
     'sanitize_callback' => 'sanitize_hex_color',
     'capability' => 'edit_posts',

In (the heading of) your author.php you will need to get the id of the author of the current page to retrieve the relevant mod.

$author_id = get_the_author_meta('ID');
get_mod('header_color_' . $author_id);
  • How it can be saved and read from user_meta? Can it be achieved any way? – mha Jun 15 '16 at 22:28
  • I'm afraid I don't understand your question. The customizer has a 'save' button. You retrieve the saved data with get_mod. You don't need to write save or read functions yourself. – cjbj Jun 16 '16 at 6:37
  • I want customizer data to save in user_meta field instead of in wp_option table. This way each user will have their own data on user_meta table. And with this data each author.php page can be modified. How can I achieve this? – mha May 23 '17 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.