SIERRA Posted June 21, 2018 Posted June 21, 2018 (edited) Hi I am not able to delete a repeater item This code works $subscriptionpage = $pages->get(1442); $subscription = $subscriptionpage->subscriptions->first(); // or whatever item you want to remove echo $subscription; $subscriptionpage->subscriptions->remove($subscription); $subscriptionpage->of(false); $subscriptionpage->save(); But this code does not works. $subscriptionpage = $pages->get(1442); $subscriptions=$subscriptionpage->subscriptions->find("email={email@mysite.com}"); echo $subscription; $subscriptionpage->subscriptions->remove($subscription); $subscriptionpage->of(false); $subscriptionpage->save(); I checked the value of $subscriptions. Both has the same value. Could you please suggest. Thanks Edited June 21, 2018 by SIERRA
SIERRA Posted June 21, 2018 Author Posted June 21, 2018 $subscriptions=$subscriptionpage->subscriptions->find("email={email@mysite.com}"); should be $subscription=$subscriptionpage->subscriptions->find("email={email@mysite.com}"); Even then this is not working
Tom. Posted June 21, 2018 Posted June 21, 2018 Well when you use "{email@mysite.com}" usually that means email@mysite.com is a variable. Such as "$email@mysite.com = 'tom@pw.com'". Obviously that wouldn't work. If you have a repeater that has a field email and the field has a value of 'email@mysite.com' then you need to use $subscription = $subscriptionpage->subscriptions->find("email='email@mysite.com'"); As the string needs to be escaped. Edit: One thing that will help you is echoing $subscription wouldn't really work as it returns a PageArray. I would use echo $subscription->count as that will return if it found a match or not. If it's returning 0 that's why it will not delete anything.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now