Custom Functions as Plugin

Home Forums Quform WordPress Custom Functions as Plugin

This topic is: resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #16920
    kpudlo
    Participant

    Hello,

    I was looking up how to create custom functions as a plugin, as I’d rather not mess with the functions.php of every theme.

    I was referencing both Create and Edit Database Rows AND Adding WP user name and user last name to the database

    For my php file I have the following
    <?php
    /*
    Plugin Name: TSG Quform Values
    Plugin URI: http://koinonian.net
    Description: TSG Form values for Quform
    Version: 1.0
    Author: Kevin Pudlo
    Author URI: http://koinonian.net
    License: GPL
    */

    function tsg_userid($value)
    {
    if (is_user_logged_in()) {
    global $current_user;
    get_currentuserinfo();
    $value = $current_user->user_id;
    }

    return $value;
    }
    add_filter('iphorm_element_value_userid', 'tsg_userid');

    ?>

    I have the plugin installed, and have built a form with a single text line, dynamic value checked with a parameter of userid, but nothing shows up.

    Thank you,
    Kevin

    #16921
    kpudlo
    Participant

    Nevermind, I had a wrong value!

    function tsg_userid($value)
    {
    if (is_user_logged_in()) {
    global $current_user;
    get_currentuserinfo();
    $value = $current_user->user_id;
    }

    Should be

    function tsg_userid($value)
    {
    if (is_user_logged_in()) {
    global $current_user;
    get_currentuserinfo();
    $value = $current_user->ID;
    }

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy