If you find by yourself, then you understand the mechanism and it is much better for everybody.
I give you another clue :
$cid is not initializated in your function !!
function movetoregistered()
{
//HERE YOU PROTECT FROM DIRECT CALL (need a unique session token)
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
//HERE YOU INITIALIZE $cid
$cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
//CHECK ACL (based on core.edit, but you can change it)
if (!$this->can('core.edit', JText::_("JTOOLBAR_YOUR_NEW_TASK_FUNCTON_NAME") ))
return;
//PROCESS THE COPY
$model1 = JModel::getInstance('Unregisteredpins', 'PinsModel');
$model2 = JModel::getInstance('Registeredpins', 'PinsModel');
//Here, you can place a loop to execute on multiple items
$cid = $cid[0];
$model1->setId($cid);
$element = $model1->getData();
$element->id = 0; //Reset the ID
$result = false;
if($model2->save($element)) //COPY
if ($model1->delete()){ //DELETE PREVIOUS
$result = true;
}
if ($result)
{
//Redirect if success
$vars = array();
JRequest::setVar( 'view' , '...');
JRequest::setVar( 'layout', '...' );
//JRequest::setVar( 'cid', null );
$this->setRedirect(XxxxHelper::urlRequest($vars));
}
else
{
//Redirect if fails ...
//Reproduce a custom redirection if you want ...
// OR keep the post and stay on page
parent::display();
}
}
Now, the next step is to place a custom toolbar button to launch this task.
For the moment I am not sure you can do it easily with JDom (must check it)
Try to get it out
You can try by url if you COMMENT the token check.
(If you don't, it will you output 'Invalid Token')
index.php?option=...&task=movetoregistered&cid[]=##
I also cannot help you more because I don't have really the time to test it.
Helping you is really a gift because I am passionated, but I should concentrate myself on the support only.