Tagged: , ,

Viewing 5 reply threads
  • Author
    Posts
    • #8873
      thor
      Member

      How would you set up a field, that reflects the current user.

      piklist('field', array(
      	'type' => 'text',
      	'field' => 'my_filed'+currentusersIDhere,
      	....

      Would it work and be safe to use the users id integer?

    • #8895
      Steve
      Keymaster

      @thor– Try adding this to your form file:

      
        piklist('field', array(
          'type' => 'hidden'
          ,'scope' => 'user'
          ,'field' => 'ID'
          ,'value' => $user_id  //pass the id here
        ));
      
    • #8896
      thor
      Member

      Thanks @Steve.

      But I am not sure if it will work in my case.

      Imagine a site with authors, that each have their public “author profile page” – where they have som featured posts.

      I want to use piklist to have a checkbox saying “feature this post” (which will determine if the post is shown on their author page). So this box is per user, hence I was wondering if ‘field’ => ‘my_featured_post_’+$user_id would be the best approach? Each user would only see their own “feature this post” field.

    • #8897
      Steve
      Keymaster

      Save the field as scope => user, and it will save to user meta. Then you can pull that meta per user. Does that make sense?

    • #8898
      thor
      Member

      ah yes, I think that makes sense 🙂

    • #8899
      Steve
      Keymaster

      Great! Let us know if you need any more help. Closing this ticket.

Viewing 5 reply threads
  • The topic ‘field reflecting current user’ is closed to new replies.