4

I created a theme and use Themes Customizer. Is there any way I can give anonymous users access to the themes customizer without the ability to save it?

It will be very convenient in terms of user experience if users are able to know what kind of theme customization we offer and how they can change it.

Thank you

  • Similar question – Sisir May 21 '14 at 11:00
  • You are a theme developer? Why not dump and reset the database cyclically-- say, once a day-- like many software demo sites do? – s_ha_dum May 21 '14 at 13:16
  • I know this is possible but I unfortunately haven't found out how to do it yet. I have seen examples of this e.g. settler.themepatio.com/wp-admin/customize.php Here the user can click "Save and Publish" but any changes made are discarded when the customizer is closed. – alexgophermix May 23 '14 at 19:04
  • fortunately i found a way how to do this without hacking on WordPress core. this method will need to having user, but they won't need to login. i will write down how to do it soon. Cheers! – Jeg Bagus May 23 '14 at 23:55
  • 2
    Hi Jeg, have you posted your solution somewhere yet? – alexgophermix Jul 16 '14 at 16:22
0

Try using this solution to give access to users to a specific page without them having to register an account.

http://codex.wordpress.org/Function_Reference/wp_signon

Let me know if it does not work or you need further help.

  • Could you add some sample code and explanation to the answer? It would make the answer much better. – cybmeta May 8 '15 at 12:50
0

Its bit tricky how implementation to let anonymous user to log into your themes customizer. here is step by step i use :

  1. first is to create user with demo role (demo role is not available on WordPress, so you will need to write code like bellow to add demo role)

    function jeg_demo_role () { add_role( 'demo', 'Demo', array( 'read' => true, 'edit_theme_options' => true, 'edit_posts' => false, 'delete_posts' => false )); } add_action('init', 'jeg_demo_role');

  2. now you will need to create template that will log user automatically and redirect them to theme customizer.

    /** Template Name: Demo - Theme Customizer */

    $creds = array( 'user_login' => 'demo', 'user_password' => 'demo' );

    $user = wp_signon( $creds, false );

    if ( is_wp_error( $user ) ) { echo $user->get_error_message(); } else { $customizerurl = get_admin_url() . 'customize.php'; wp_redirect( $customizerurl ); } exit;

  3. don't forget your customizer, and disable save option on customizer

    function jeg_is_demo_user() { if(is_user_logged_in()) { $current_user = wp_get_current_user(); if($current_user->roles[0] === 'demo') { return true; } } return false; }

    /** disable save on demo */ function jeg_customize_save() { if(jeg_is_demo_user()) { exit; } } add_action('customize_save', 'jeg_customize_save');

  4. Then you will only need to create page with those template, and when your user head to those url, they will automatically redirected into other page.

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.