WordPress.org

Ready to get started?Download WordPress

Forums

People Lists
Executing PHP in a template (8 posts)

  1. JamTheMan
    Member
    Posted 3 years ago #

    Hi

    I am working on creating a user list using your plugin, and so far it works great!

    I just can't seem to get the last pieces of the puzzle to match my needs. I would really like to be able to exec some PHP within the template (I have the Exec PHP plugin installed). More precisely, I would like have a line like this work from inside the template:

    <?php echo get_user_meta( %id%, 'weapon', true); ?>

    Using %id% as one of the defaults you supply. I know I could just make the "weapon" field as an added field through your plugin, but it has already been made for all my users, and reconfiguring all of them would be a bore. Can this be done?

    Thx,
    JamTheMan

  2. JamTheMan
    Member
    Posted 3 years ago #

    BTW...

    The real problem is that somewhere the PHP gets caught and put into a comment instead, and therefore is not received by the Exec PHP plugin.

    The Chrome Inspector shows this line instead:

    <!--?php echo get_user_meta( %id%, 'weapon', true); ?-->

  3. enej
    Member
    Plugin Contributor

    Posted 3 years ago #

    Hi JamTheMan

    I don't think you need to do that.
    There is a way to create custom user meta fields in the user profile. and to display them in the template. Have you figured out how to do that? Let me know if the UI is not so straight forward.

    Cheers

  4. JamTheMan
    Member
    Posted 3 years ago #

    Yeah... I now that... And that btw works great!

    The thing is just that I already have all the extra user details added to the WordPress profiles, with another plugin, and it would therefore be much easier if i could use those values in your plugin, instead of remaking them all...

    This of cause could be done with some rather simple SQL updates, but then it would be great if all the custom meta fields were not added under "Contact Info" in the user profile, but maybe under a new node called "Other Info" or something. Just makes more sense to the users in case the new fields have nothing to do with contact info...

    So if there is no way to allow the PHP to go through, I'll just have to do it the other way. Thanks in any case---

    -Jam

  5. enej
    Member
    Plugin Contributor

    Posted 3 years ago #

    Hi Jam

    I am thinking about adding a filter to the plugin that will allow you to add your own tags and quiery the stuff easier in your case. This way you will be able to extend the plugin for your needs and not worry about modifying it for the future case. I will write a short tutorial that will do that. Would that work for your case?

    Cheers Enej

  6. JamTheMan
    Member
    Posted 3 years ago #

    Yeah, that sounds like it would be perfect...

    Thanks so much :-D

  7. aplussideas
    Member
    Posted 3 years ago #

    Hi Enej,

    Congrats on the great plug-in. I have the exact same need as Jam (to have the ability to render a shortcode from another plug-in into the template).

    You mentioned you were working on adding a filter and writing a short tutorial on how to use this. Have you made any progress on this?

    Thanks!!

  8. enej
    Member
    Plugin Contributor

    Posted 3 years ago #

    Hi aplussideas and Jam

    I am sorry I didn't post some sort of tutorial earlier. If you look at the code and are compftable with filters. you can use the
    'people_list_shortcode' filter to change the html that is being ouputed to the theme.

    try something like

    add_filter('people_list_shortcode','example_people_list_shortcode',10); //
    function example_people_list_shortcode($html){
    return $html."the end of the template";
    };

    you can also try the 'people_list_fields_display' filer
    and the
    'people_list_custom_fields'

    look at the code in the file people-list.php starting at line 726 for more info.

    I hope that helps

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic