Viewing 7 reply threads
  • Author
    Posts
    • #3458
      vsalda
      Member

      I’m testing Piklist on my local machine. I activated the Piklist’s demos and checking the User profile part I noticed that ‘Default’ workflow tab isn’t displaying any info.
      I debugged this part and I noticed two things:

      1. Class class-piklist-user.php seems to be in charge of registering User Profile fields. Around line 325, inside the conditional if (isset($arguments['meta_boxes'])), it counts the availabe metaboxes available on self::$meta_boxes , which contains 13 and this number matches the available fields under /piklist-demos/parts/users , but there’s no file registering the User Profile fields.

      2. Under /piklist-demos/parts/forms there’s a file named user-profile.php which registers profile’s fields that matches with those the user-default.php is trying to load.

      By the time if (!in_array(self::$meta_boxes[$i]['config']['name'], $arguments['meta_boxes'])) is run (on class-piklist-user.php), $arguments['meta_boxes'] contains just five values: Personal Options, Name, Contact Info, About the user, About Yourself which aren’t part of self::$meta_boxes[$i], so it goes and unsets: unset(self::$meta_boxes[$i]).

      My question is, as I couldn’t find any reference on the documentation, how is /parts/forms/ used?? And for the profile’s default workflow tab to work, seems a file is missing inside ‘/parts/users/`in order to register this fields, is it right??

      Thanks for any hint that helps me clarify things.
      Victor

      Attachments:
      You must be logged in to view attached files.
    • #3460
      vsalda
      Member

      I’ve been checking the code for the forms part, and I found it is handled by the class-piklist-form.php and it is used to generated forms in the front end by using a shortcode, awesome.

      So I guess I should add the fields needed for the default workflow tab to work.

      Victor

    • #3461
      Steve
      Keymaster

      @vsalda– Welcome to the Piklist Community!

      Forms is not the folder you want to look in. Can you check: piklist > add-ons > piklist-demos > parts > workflows. Does the file look like this?

    • #3462
      vsalda
      Member

      Hi @Steve, yup, that’s the file I was checking before and the one that took me to class-piklist-user.php, but when debugging, these metaboxes aren’t part of self::$meta_boxes[$i][‘config’][‘name’] and therefore $arguments[‘meta_boxes’] is unset. So I suspect it is because these fields aren’t in the /parts/users folder, I’m guessing by following the flow, just getting familiar with Piklist. So, should i add these fields under /parts/users or it is supposed to work just by activating? but I don’t see where user-default.php is pulling these ‘meta_boxes’ from.

    • #3463
      Steve
      Keymaster

      @vsalda– This is the first time we’ve heard of this issue. Please deactivate all other plugins and switch to the WordPress default theme and see if that fixes the issue>

      • #4309
        okeanos
        Member

        Hi there !

        I also have this pb (wp 4.3) : the default user tab is empty (same pb with the piklist demo files).

        Any clue ?

    • #3465
      vsalda
      Member

      @Steve, it didn’t work. It’s a fresh install with only WordPress Importer and Piklist plugins active with Twentyfifteen theme and PHP 5.6.5. I will give it another try later. Thanks!

      • #4310
        okeanos
        Member

        I just answer to myself. I found out the pb is about localization. My wp was in french and changing for english solved the issue.

        For those who are trying to find a solution, it seems that by just adding the translated version of $meta_boxes it is working.

        In the file admin-user-profile-fields.php, change :

        var meta_boxes = ['<?php echo implode("', '", $meta_boxes); ?>'];

        to

              <?php 
                $translated_metaboxes = array();
                foreach ($meta_boxes as $meta_box) {
                  $translated_metaboxes[] = __($meta_box);
                }
               ?>
        
              var meta_boxes = ['<?php echo implode("', '", $translated_metaboxes); ?>'];  
        
        
      • #4314
        Steve
        Keymaster

        @okeanos– It must be something additional. I tested a French install and everything worked as expected. Do you have any localization plugins activated as well?

      • #4321
        okeanos
        Member

        @Steve I don’t use localization plugin.

    • #3467
      vsalda
      Member

      I guess I’m getting closer, I modified the user-default.php to look like this:

      <?php
      /*
      Title: Default
      Order: 10
      Flow: User Test
      Default: true
      */
        
        piklist('include_user_profile_fields', array(
          'meta_boxes' => array(
            'User Info'
          )
        ));
      
        piklist('shared/code-locater', array(
          'location' => __FILE__
          ,'type' => 'Workflow Tab'
        ));
      
      ?>
      

      And added a file user-info.php to /parts/users containing:

      <?php
      /*
      Title: User Info
      Capability: manage_options
      Order: 10
      */
      
      $current_user = wp_get_current_user();
      $user_meta = get_user_meta($current_user->ID);
      
      piklist('field', array(
          'type' => 'hidden'
          ,'scope' => 'user'
          ,'field' => 'ID'
          ,'value' => $current_user->ID
      ));
      
      
      piklist('field', array(
          'type' => 'html'
          ,'scope' => 'user'
          ,'field' => 'user_login'
          ,'label' => 'User login'
          ,'value' => $current_user->user_login
      ));
      
      piklist('field', array(
          'type' => 'password'
          ,'scope' => 'user'
          ,'field' => 'user_pass'
          ,'label' => 'Password'
      ));
      
      piklist('field', array(
          'type' => 'text'
          ,'scope' => 'user_meta'
          ,'field' => 'first_name'
          ,'label' => 'First name'
          ,'value' => $user_meta['first_name'][0]
      ));
      
      piklist('field', array(
          'type' => 'text'
          ,'scope' => 'user_meta'
          ,'field' => 'last_name'
          ,'label' => 'Last name'
          ,'value' => $user_meta['last_name'][0]
      ));
      
      piklist('field', array(
          'type' => 'text'
          ,'scope' => 'user_meta'
          ,'field' => 'nickname'
          ,'label' => 'Nickname'
          ,'value' => $user_meta['nickname'][0]
      ));
      
      piklist('field', array(
          'type' => 'text'
          ,'scope' => 'user'
          ,'field' => 'display_name'
          ,'label' => 'Display name'
          ,'value' => $current_user->display_name
      ));
      
      
      piklist('field', array(
          'type' => 'text'
          ,'scope' => 'user'
          ,'field' => 'user_email'
          ,'label' => 'Email'
          ,'value' => $current_user->user_email
          ,'required' => true
      ));
      
      piklist('field', array(
          'type' => 'text'
          ,'scope' => 'user'
          ,'field' => 'user_url'
          ,'label' => 'Website'
          ,'value' => $current_user->user_url
      ));
      
      piklist('field', array(
          'type' => 'text'
          ,'scope' => 'user_meta'
          ,'field' => 'user_twitter'
          ,'label' => 'Twitter ID'
          ,'value' => $user_meta['user_twitter'][0]
      ));
      
      piklist('field', array(
          'type' => 'text'
          ,'scope' => 'user_meta'
          ,'field' => 'description'
          ,'label' => 'Biographical Info'
          ,'value' => $user_meta['description'][0]
      ));
      
      
      piklist('field', array(
          'type' => 'checkbox'
          ,'scope' => 'user_meta'
          ,'field' => 'checkbox'
          ,'label' => 'Keyboard Shortcuts'
          ,'choices' => array(
              'true' => __('Enable keyboard shortcuts for comment moderation.', 'piklist-demo')
          )
      ));
      
      piklist('field', array(
          'type' => 'checkbox'
          ,'scope' => 'user_meta'
          ,'field' => 'checkbox'
          ,'label' => 'Toolbox'
          ,'choices' => array(
              'true' => __('Show Toolbar when viewing site', 'piklist-demo')
          )
      ));
      
      piklist('shared/code-locater', array(
          'location' => __FILE__
          ,'type' => 'Meta Box'
      ));
      

      I basically used the forms code. If I add info for First name and last name, those aren’t saved, but I works when I saved the Twitter ID. Any suggestion to get the user meta saved? Am I missing a paramater?

      Thanks in advance

    • #4328
      Steve
      Keymaster

      @vsalda– Why are you trying to override the default WordPress form for users?

Viewing 7 reply threads
  • You must be logged in to reply to this topic.