Jump to content

Rich Torres

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by Rich Torres

  1. I am a bit confused. I have a simple form to add new users, and I damn near have everything working. As a matter of fact it WAS working just fine a few times while testing. I really changed very little. The role "representative" exists yet I still get an error:

    Quote

    Error: Exception: Method NullPage::addRole does not exist or is not callable in this context



     

    <form method="post" action="./">
      <label for="firstName">First Name</label>
      <input name="firstName" type="text" required>
      <label for="lastName">Last Name</label>
      <input name="lastName" type="text" required>
      <label for="email">Email</label>
      <input name="email" type="email" required>
      
      <button name="submit" type="submit">Get Started</button>
    </form>
    
    <?php
    
    if (isset($_POST['submit'])) {
            // Puts users in an array, and finds a userID that is not being used
            $agentList = array();
            $number = 1001;
    
            foreach($users->find('start=0, roles=representative') as $v) {
                    array_push($agentList, $v->userID);
            }
    
            for ($number; ;) {
                    if(in_array($number, $agentList)) {
                            $number++;
                    } else {
                            $newAgentID = $number;
                            break;
                    }
            }
            // Place POST data into variables
            $firstName = $_POST['firstName'];
            $lastName = $_POST['lastName'];
            $fullName = array($firstName,$lastName);
            $email = $_POST['email'];
          
            //Have Processwire add the new user     
            $u = $users->add($firstName[0].$lastName);
            $u->firstName = $firstName;
            $u->lastName = $lastName;
            $u->pass = "Password";
            $u->addRole('representative');
            $u->email = $email;
            $u->userID = $newAgentID;
            $u->save();
    
            //Add user to ViciDial
            $viciAdminUser = 10;
            $viciAdminPass = "password";
            $viciUser = $newAgentID;
            $viciUserName = implode(" ",$fullName);
            $viciUserPass = "Password".$newAgentID;  
            $viciUserLevel = 1;
            $viciUserGroup = "Arizona";
    }       

     

  2. I'm an idiot... page reference field on home page... all those duckduckgo searches... wasted :'(:lol:

    abdus, thank you for such a hasty reply. I will make note of this, as I am sure this will help me further my understanding. I am sure this info will come in useful in the near future.

  3. Hello there fellow PW people,

    I am looking to feature a different page every week on the home page. I am building this web site, but not maintaining the content. I wanted some thing like a checkbox that would turn a page into a 'featured' page. this checkbox could only be used by one page at any given time. So if another page is chosen as featured, it would have to lose this value.

    I am kind of at a loss where to start. I have done some searching, but perhaps my keywords are not allowing something I am looking for to pop up.

    Thanks in advance!

    Rich Torres

×
×
  • Create New...