WordPress.org

Ready to get started?Download WordPress

Forums

HELP: Add new parameters to users? (5 posts)

  1. strikedamic
    Member
    Posted 6 years ago #

    Hi all
    I have a blog/review site with a few authors. My page does also have a shop, we're planning to design some fashion, so I have different people for different jobs (I usually call them functions).
    So now, I managed to add login textboxes to my sidebar so the usual wordpress login page is unnecessary. If logged in, the page shows the user's details and functions instead of the login stuff.
    Until now, I have added user's functions by manually echoing their functions in a if-else-endif function, e.g.:

    if (1 == $user_ID) {
    echo ('Admin, Author');
    }
    if (2 == $user_ID) {
    echo ('Author, Moderator');
    }

    etc.
    How can I add new parameters to the database that are linked to the different users, so I can get the functions of the current user and show them in the user infos?

    any fast help greatly appreciated.

    strike

  2. strikedamic
    Member
    Posted 6 years ago #

    Update: tried the following:

    <label><?php _e('Functions:') ?>
    <input type="text" name="func" id="func" value="<?php echo $profileuser->user_func ?>" /></label>

    (in wp-admin/profile.php)

    I guess the new value of User Function will be saved as user_func, right? The Profile area shows the new textbox nicely, but when I hit "Update", the textbox goes blank so I guess my newly defined value is not being saved.
    1. What do I have to do to make the system save the new function as user_func?
    2. What code do I have to implement in the sidebar to include the User's Function (aka user_func)?

    Please help!! Thanks

  3. alakhnor
    Member
    Posted 6 years ago #

    Here's a little plugin I wrote for my own purpose. It saves the flickr profile url in user option. You may clean it and use it for what you want to do.

    File: ptFlickR.php

    <?php
    /*
    Plugin Name: ptFlickR
    Plugin URI: http://www.alakhnor.com/post-thumb
    Description: Adds FlickR profile url to user profile screen.
    Version: 1.0
    Author:  Alakhnor
    Author URI: http://www.alakhnor.com/post-thumb
    
    	Copyright (c) 2007 Alakhnor (http://www.alakhnor.com/post-thumb) for ptFlickR
    	ptFlickR is released under the GNU General Public License (GPL)
    	http://www.gnu.org/licenses/gpl.txt
    
    	This is a WordPress 2 plugin (http://wordpress.org).
    */
    
    // Defines path & urls
    define('PTF_BASENAME', dirname(plugin_basename(__FILE__)));
    define('PTF_ABSPATH', ABSPATH.'wp-content/plugins/' . PTF_BASENAME.'/');
    
    // calls function & class files
    require(PTF_ABSPATH . 'ptFlickR-admin.php');
    
    ?>

    File: ptFlickR-admin.php

    <?php
    $PTFlickRAdmin = new pta_author_flickr_admin();
    class pta_author_flickr_admin {
    
    	/************************************************************
    	/*	constructor
    	************************************************************/
    	function pta_author_flickr_admin() {
    
                    $this->init();
    
    	}
    	/************************************************************
    	/*	init()
    	************************************************************/
    	function init() {
    
    		add_action('edit_user_profile', array(&$this, 'display_flickr'));
    		add_action('show_user_profile', array(&$this, 'display_flickr'));
    		add_action('profile_update', array(&$this, 'save_flickr'));
    	}
    	/************************************************************
    	/*	display_flickr()
    	************************************************************/
    	function display_flickr() {
    
    		$author_id = $GLOBALS['profileuser']->user_login;
    		$flickr_url = trailingslashit(get_user_option('flickrurl'));
    
    		// Input form
    		?>
    		<fieldset>
    			<legend><?php _e('Additional informations'); ?></legend>
    			<label><?php _e('FlickR profile:'); ?></label>
    			<input type="text" style="font-size: 1.2em;" name="flickrurl" value="<?php echo $flickr_url; ?>" />
    
    		</fieldset>
    		<?php
    	}
    	/************************************************************
    	/*	save_flickr()
    	************************************************************/
    	function save_flickr($user_ID) {
    
    		if (isset($_POST['flickrurl'])) {
    			$flickrprofile = $this->return_profile($_POST['flickrurl']);
    			update_user_option($user_ID, 'flickrurl', $_POST['flickrurl']);
    			update_user_option($user_ID, 'flickrprofile', $flickrprofile);
    		}
    
    		return $user_ID;
    	}
    	/************************************************************
    	/*	return_profile()
    	************************************************************/
    	function return_profile($flickrurl) {
    		return $flickrurl;
    	}
    
    } // flickr_admin
    ?>
  4. strikedamic
    Member
    Posted 6 years ago #

    Thank you for your help, but; considering I'm a real php newbie, you need to tell me how to use it for my purpose before it's of any use to me :P
    Did you understand what results I want to have? If yes, could you please alter the code and post it and tell me where I have to put those files in or if I have to activate any plugins etc?

    Thank you VERY much! :)

  5. strikedamic
    Member
    Posted 6 years ago #

    ... please? :(

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.