Forums

Change user role of one user in functions.php (8 posts)

  1. testna
    Member
    Posted 9 months ago #

    Hi,

    How to make function (argumen would be $userid), that would change user role only for this user.

    I would like to implement that in functions.php file.

  2. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    Why are you doing it in the functions, and to what purpose?

  3. testna
    Member
    Posted 9 months ago #

    I wanted that someone would get admin rights, after filling up user details in profile (name, phone number...). Before that he wouldn't have rights to add or edit pages and everything

  4. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    That would be a big security risk, since a spammer would be able to fill in the data with junk and then have admin rights.

  5. Andrea_r
    team pirate
    Posted 9 months ago #

    And you wouldn't want to do it in the functions.php file anyway, because that's *theme* based, when what you want is user based.

  6. testna
    Member
    Posted 9 months ago #

    I know it is theme based.

    How can I solve that diferently?

  7. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 9 months ago #

    Make a plugin that, when someone logs in, checks for completion of the profile. If found, promote user levels.

    And I wouldn't do it in a million years, if you paid me.

  8. Andrea_r
    team pirate
    Posted 9 months ago #

    Take the code you were going to put in functions.php and put it in a separate php file with a plugin header. then activate it as a plugin.

    or put it in the mu-plugins folder.

    And make sure you're doing a check for a specific user.

    The whole of wordpress is filled with functions. you are not require to stick them in functions.php.

Reply

You must log in to post.

About this Topic